microsoft/hve-core

Public

mirrored from https://github.com/microsoft/hve-coreAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
hve-core-v2.3.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

scripts/tests/plugins/PluginHelpers.Tests.ps1

167lines · modeblame

3156d989Katrien De Graeve5 months ago1#Requires -Modules Pester
2# Copyright (c) Microsoft Corporation.
3# SPDX-License-Identifier: MIT
4
5BeforeAll {
6Import-Module $PSScriptRoot/../../plugins/Modules/PluginHelpers.psm1 -Force
7}
8
9Describe 'Get-ArtifactFiles - hve-core path exclusion' {
10BeforeAll {
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'
16New-Item -ItemType Directory -Path $agentsDir -Force | Out-Null
17Set-Content -Path (Join-Path $agentsDir 'good.agent.md') -Value '---\ndescription: good\n---'
18
19# Create instruction files (shared)
20$instrDir = Join-Path $ghDir 'instructions'
21New-Item -ItemType Directory -Path $instrDir -Force | Out-Null
22Set-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'
26New-Item -ItemType Directory -Path $hveCoreInstrDir -Force | Out-Null
27Set-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'
31New-Item -ItemType Directory -Path $hveCoreAgentsDir -Force | Out-Null
32Set-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'
36New-Item -ItemType Directory -Path $promptsDir -Force | Out-Null
37Set-Content -Path (Join-Path $promptsDir 'gen-plan.prompt.md') -Value '---\ndescription: prompt\n---'
38}
39
40It '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
46It '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
52It '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
58It '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
64It '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
71Describe 'Resolve-CollectionItemMaturity' {
72It 'Returns stable for null' {
73$result = Resolve-CollectionItemMaturity -Maturity $null
74$result | Should -Be 'stable'
75}
76
77It 'Returns stable for empty string' {
78$result = Resolve-CollectionItemMaturity -Maturity ''
79$result | Should -Be 'stable'
80}
81
82It 'Returns stable for whitespace' {
83$result = Resolve-CollectionItemMaturity -Maturity ' '
84$result | Should -Be 'stable'
85}
86
87It 'Passes through preview' {
88$result = Resolve-CollectionItemMaturity -Maturity 'preview'
89$result | Should -Be 'preview'
90}
91
92It 'Passes through experimental' {
93$result = Resolve-CollectionItemMaturity -Maturity 'experimental'
94$result | Should -Be 'experimental'
95}
96}
97
98Describe 'Test-ArtifactDeprecated' {
99It 'Returns true for deprecated' {
100$result = Test-ArtifactDeprecated -Maturity 'deprecated'
101$result | Should -BeTrue
102}
103
104It 'Returns false for stable' {
105$result = Test-ArtifactDeprecated -Maturity 'stable'
106$result | Should -BeFalse
107}
108
109It 'Returns false for preview' {
110$result = Test-ArtifactDeprecated -Maturity 'preview'
111$result | Should -BeFalse
112}
113
114It 'Returns false for experimental' {
115$result = Test-ArtifactDeprecated -Maturity 'experimental'
116$result | Should -BeFalse
117}
118
119It 'Returns false for null (defaults to stable)' {
120$result = Test-ArtifactDeprecated -Maturity $null
121$result | Should -BeFalse
122}
123}
124
125Describe 'Get-PluginItemName' {
126It 'Strips .agent.md suffix' {
127$result = Get-PluginItemName -FileName 'task-researcher.agent.md' -Kind 'agent'
128$result | Should -Be 'task-researcher.md'
129}
130
131It 'Strips .prompt.md suffix' {
132$result = Get-PluginItemName -FileName 'gen-plan.prompt.md' -Kind 'prompt'
133$result | Should -Be 'gen-plan.md'
134}
135
136It 'Strips .instructions.md suffix' {
137$result = Get-PluginItemName -FileName 'csharp.instructions.md' -Kind 'instruction'
138$result | Should -Be 'csharp.md'
139}
140
141It '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
147Describe 'Get-PluginSubdirectory' {
148It 'Maps agent to agents' {
149$result = Get-PluginSubdirectory -Kind 'agent'
150$result | Should -Be 'agents'
151}
152
153It 'Maps prompt to commands' {
154$result = Get-PluginSubdirectory -Kind 'prompt'
155$result | Should -Be 'commands'
156}
157
158It 'Maps instruction to instructions' {
159$result = Get-PluginSubdirectory -Kind 'instruction'
160$result | Should -Be 'instructions'
161}
162
163It 'Maps skill to skills' {
164$result = Get-PluginSubdirectory -Kind 'skill'
165$result | Should -Be 'skills'
166}
167}