microsoft/hve-core
Publicmirrored fromhttps://github.com/microsoft/hve-coreAvailable
scripts/tests/plugins/PluginHelpers.Tests.ps1
167lines · modecode
| 1 | #Requires -Modules Pester |
| 2 | # Copyright (c) Microsoft Corporation. |
| 3 | # SPDX-License-Identifier: MIT |
| 4 | |
| 5 | BeforeAll { |
| 6 | Import-Module $PSScriptRoot/../../plugins/Modules/PluginHelpers.psm1 -Force |
| 7 | } |
| 8 | |
| 9 | Describe 'Get-ArtifactFiles - hve-core path exclusion' { |
| 10 | BeforeAll { |
| 11 | $script:repoRoot = Join-Path $TestDrive 'repo' |
| 12 | $ghDir = Join-Path $script:repoRoot '.github' |
| 13 | |
| 14 | # Create agent files |
| 15 | $agentsDir = Join-Path $ghDir 'agents' |
| 16 | New-Item -ItemType Directory -Path $agentsDir -Force | Out-Null |
| 17 | Set-Content -Path (Join-Path $agentsDir 'good.agent.md') -Value '---\ndescription: good\n---' |
| 18 | |
| 19 | # Create instruction files (shared) |
| 20 | $instrDir = Join-Path $ghDir 'instructions' |
| 21 | New-Item -ItemType Directory -Path $instrDir -Force | Out-Null |
| 22 | Set-Content -Path (Join-Path $instrDir 'shared.instructions.md') -Value '---\ndescription: shared\n---' |
| 23 | |
| 24 | # Create repo-specific files under .github/instructions/hve-core/ |
| 25 | $hveCoreInstrDir = Join-Path $instrDir 'hve-core' |
| 26 | New-Item -ItemType Directory -Path $hveCoreInstrDir -Force | Out-Null |
| 27 | Set-Content -Path (Join-Path $hveCoreInstrDir 'workflows.instructions.md') -Value '---\ndescription: repo-specific\n---' |
| 28 | |
| 29 | # Create repo-specific files under .github/agents/hve-core/ |
| 30 | $hveCoreAgentsDir = Join-Path $agentsDir 'hve-core' |
| 31 | New-Item -ItemType Directory -Path $hveCoreAgentsDir -Force | Out-Null |
| 32 | Set-Content -Path (Join-Path $hveCoreAgentsDir 'internal.agent.md') -Value '---\ndescription: repo-specific agent\n---' |
| 33 | |
| 34 | # Create a prompt file |
| 35 | $promptsDir = Join-Path $ghDir 'prompts' |
| 36 | New-Item -ItemType Directory -Path $promptsDir -Force | Out-Null |
| 37 | Set-Content -Path (Join-Path $promptsDir 'gen-plan.prompt.md') -Value '---\ndescription: prompt\n---' |
| 38 | } |
| 39 | |
| 40 | It 'Excludes files under .github/instructions/hve-core/' { |
| 41 | $items = Get-ArtifactFiles -RepoRoot $script:repoRoot |
| 42 | $paths = $items | ForEach-Object { $_.path } |
| 43 | $paths | Should -Not -Contain '.github/instructions/hve-core/workflows.instructions.md' |
| 44 | } |
| 45 | |
| 46 | It 'Excludes files under .github/agents/hve-core/' { |
| 47 | $items = Get-ArtifactFiles -RepoRoot $script:repoRoot |
| 48 | $paths = $items | ForEach-Object { $_.path } |
| 49 | $paths | Should -Not -Contain '.github/agents/hve-core/internal.agent.md' |
| 50 | } |
| 51 | |
| 52 | It 'Includes shared instruction files' { |
| 53 | $items = Get-ArtifactFiles -RepoRoot $script:repoRoot |
| 54 | $paths = $items | ForEach-Object { $_.path } |
| 55 | $paths | Should -Contain '.github/instructions/shared.instructions.md' |
| 56 | } |
| 57 | |
| 58 | It 'Includes non-hve-core agent files' { |
| 59 | $items = Get-ArtifactFiles -RepoRoot $script:repoRoot |
| 60 | $paths = $items | ForEach-Object { $_.path } |
| 61 | $paths | Should -Contain '.github/agents/good.agent.md' |
| 62 | } |
| 63 | |
| 64 | It 'Includes prompt files' { |
| 65 | $items = Get-ArtifactFiles -RepoRoot $script:repoRoot |
| 66 | $paths = $items | ForEach-Object { $_.path } |
| 67 | $paths | Should -Contain '.github/prompts/gen-plan.prompt.md' |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | Describe 'Resolve-CollectionItemMaturity' { |
| 72 | It 'Returns stable for null' { |
| 73 | $result = Resolve-CollectionItemMaturity -Maturity $null |
| 74 | $result | Should -Be 'stable' |
| 75 | } |
| 76 | |
| 77 | It 'Returns stable for empty string' { |
| 78 | $result = Resolve-CollectionItemMaturity -Maturity '' |
| 79 | $result | Should -Be 'stable' |
| 80 | } |
| 81 | |
| 82 | It 'Returns stable for whitespace' { |
| 83 | $result = Resolve-CollectionItemMaturity -Maturity ' ' |
| 84 | $result | Should -Be 'stable' |
| 85 | } |
| 86 | |
| 87 | It 'Passes through preview' { |
| 88 | $result = Resolve-CollectionItemMaturity -Maturity 'preview' |
| 89 | $result | Should -Be 'preview' |
| 90 | } |
| 91 | |
| 92 | It 'Passes through experimental' { |
| 93 | $result = Resolve-CollectionItemMaturity -Maturity 'experimental' |
| 94 | $result | Should -Be 'experimental' |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | Describe 'Test-ArtifactDeprecated' { |
| 99 | It 'Returns true for deprecated' { |
| 100 | $result = Test-ArtifactDeprecated -Maturity 'deprecated' |
| 101 | $result | Should -BeTrue |
| 102 | } |
| 103 | |
| 104 | It 'Returns false for stable' { |
| 105 | $result = Test-ArtifactDeprecated -Maturity 'stable' |
| 106 | $result | Should -BeFalse |
| 107 | } |
| 108 | |
| 109 | It 'Returns false for preview' { |
| 110 | $result = Test-ArtifactDeprecated -Maturity 'preview' |
| 111 | $result | Should -BeFalse |
| 112 | } |
| 113 | |
| 114 | It 'Returns false for experimental' { |
| 115 | $result = Test-ArtifactDeprecated -Maturity 'experimental' |
| 116 | $result | Should -BeFalse |
| 117 | } |
| 118 | |
| 119 | It 'Returns false for null (defaults to stable)' { |
| 120 | $result = Test-ArtifactDeprecated -Maturity $null |
| 121 | $result | Should -BeFalse |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | Describe 'Get-PluginItemName' { |
| 126 | It 'Strips .agent.md suffix' { |
| 127 | $result = Get-PluginItemName -FileName 'task-researcher.agent.md' -Kind 'agent' |
| 128 | $result | Should -Be 'task-researcher.md' |
| 129 | } |
| 130 | |
| 131 | It 'Strips .prompt.md suffix' { |
| 132 | $result = Get-PluginItemName -FileName 'gen-plan.prompt.md' -Kind 'prompt' |
| 133 | $result | Should -Be 'gen-plan.md' |
| 134 | } |
| 135 | |
| 136 | It 'Strips .instructions.md suffix' { |
| 137 | $result = Get-PluginItemName -FileName 'csharp.instructions.md' -Kind 'instruction' |
| 138 | $result | Should -Be 'csharp.md' |
| 139 | } |
| 140 | |
| 141 | It 'Returns skill directory name unchanged' { |
| 142 | $result = Get-PluginItemName -FileName 'video-to-gif' -Kind 'skill' |
| 143 | $result | Should -Be 'video-to-gif' |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | Describe 'Get-PluginSubdirectory' { |
| 148 | It 'Maps agent to agents' { |
| 149 | $result = Get-PluginSubdirectory -Kind 'agent' |
| 150 | $result | Should -Be 'agents' |
| 151 | } |
| 152 | |
| 153 | It 'Maps prompt to commands' { |
| 154 | $result = Get-PluginSubdirectory -Kind 'prompt' |
| 155 | $result | Should -Be 'commands' |
| 156 | } |
| 157 | |
| 158 | It 'Maps instruction to instructions' { |
| 159 | $result = Get-PluginSubdirectory -Kind 'instruction' |
| 160 | $result | Should -Be 'instructions' |
| 161 | } |
| 162 | |
| 163 | It 'Maps skill to skills' { |
| 164 | $result = Get-PluginSubdirectory -Kind 'skill' |
| 165 | $result | Should -Be 'skills' |
| 166 | } |
| 167 | } |
| 168 | |