#Requires -Modules Pester
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
BeforeAll {
Import-Module $PSScriptRoot/../../plugins/Modules/PluginHelpers.psm1 -Force
}
Describe 'Get-ArtifactFiles - hve-core path exclusion' {
BeforeAll {
$script:repoRoot = Join-Path $TestDrive 'repo'
$ghDir = Join-Path $script:repoRoot '.github'
# Create agent files
$agentsDir = Join-Path $ghDir 'agents'
New-Item -ItemType Directory -Path $agentsDir -Force | Out-Null
Set-Content -Path (Join-Path $agentsDir 'good.agent.md') -Value '---\ndescription: good\n---'
# Create instruction files (shared)
$instrDir = Join-Path $ghDir 'instructions'
New-Item -ItemType Directory -Path $instrDir -Force | Out-Null
Set-Content -Path (Join-Path $instrDir 'shared.instructions.md') -Value '---\ndescription: shared\n---'
# Create repo-specific files under .github/instructions/hve-core/
$hveCoreInstrDir = Join-Path $instrDir 'hve-core'
New-Item -ItemType Directory -Path $hveCoreInstrDir -Force | Out-Null
Set-Content -Path (Join-Path $hveCoreInstrDir 'workflows.instructions.md') -Value '---\ndescription: repo-specific\n---'
# Create repo-specific files under .github/agents/hve-core/
$hveCoreAgentsDir = Join-Path $agentsDir 'hve-core'
New-Item -ItemType Directory -Path $hveCoreAgentsDir -Force | Out-Null
Set-Content -Path (Join-Path $hveCoreAgentsDir 'internal.agent.md') -Value '---\ndescription: repo-specific agent\n---'
# Create a prompt file
$promptsDir = Join-Path $ghDir 'prompts'
New-Item -ItemType Directory -Path $promptsDir -Force | Out-Null
Set-Content -Path (Join-Path $promptsDir 'gen-plan.prompt.md') -Value '---\ndescription: prompt\n---'
}
It 'Excludes files under .github/instructions/hve-core/' {
$items = Get-ArtifactFiles -RepoRoot $script:repoRoot
$paths = $items | ForEach-Object { $_.path }
$paths | Should -Not -Contain '.github/instructions/hve-core/workflows.instructions.md'
}
It 'Excludes files under .github/agents/hve-core/' {
$items = Get-ArtifactFiles -RepoRoot $script:repoRoot
$paths = $items | ForEach-Object { $_.path }
$paths | Should -Not -Contain '.github/agents/hve-core/internal.agent.md'
}
It 'Includes shared instruction files' {
$items = Get-ArtifactFiles -RepoRoot $script:repoRoot
$paths = $items | ForEach-Object { $_.path }
$paths | Should -Contain '.github/instructions/shared.instructions.md'
}
It 'Includes non-hve-core agent files' {
$items = Get-ArtifactFiles -RepoRoot $script:repoRoot
$paths = $items | ForEach-Object { $_.path }
$paths | Should -Contain '.github/agents/good.agent.md'
}
It 'Includes prompt files' {
$items = Get-ArtifactFiles -RepoRoot $script:repoRoot
$paths = $items | ForEach-Object { $_.path }
$paths | Should -Contain '.github/prompts/gen-plan.prompt.md'
}
}
Describe 'Resolve-CollectionItemMaturity' {
It 'Returns stable for null' {
$result = Resolve-CollectionItemMaturity -Maturity $null
$result | Should -Be 'stable'
}
It 'Returns stable for empty string' {
$result = Resolve-CollectionItemMaturity -Maturity ''
$result | Should -Be 'stable'
}
It 'Returns stable for whitespace' {
$result = Resolve-CollectionItemMaturity -Maturity ' '
$result | Should -Be 'stable'
}
It 'Passes through preview' {
$result = Resolve-CollectionItemMaturity -Maturity 'preview'
$result | Should -Be 'preview'
}
It 'Passes through experimental' {
$result = Resolve-CollectionItemMaturity -Maturity 'experimental'
$result | Should -Be 'experimental'
}
}
Describe 'Test-ArtifactDeprecated' {
It 'Returns true for deprecated' {
$result = Test-ArtifactDeprecated -Maturity 'deprecated'
$result | Should -BeTrue
}
It 'Returns false for stable' {
$result = Test-ArtifactDeprecated -Maturity 'stable'
$result | Should -BeFalse
}
It 'Returns false for preview' {
$result = Test-ArtifactDeprecated -Maturity 'preview'
$result | Should -BeFalse
}
It 'Returns false for experimental' {
$result = Test-ArtifactDeprecated -Maturity 'experimental'
$result | Should -BeFalse
}
It 'Returns false for null (defaults to stable)' {
$result = Test-ArtifactDeprecated -Maturity $null
$result | Should -BeFalse
}
}
Describe 'Get-PluginItemName' {
It 'Strips .agent.md suffix' {
$result = Get-PluginItemName -FileName 'task-researcher.agent.md' -Kind 'agent'
$result | Should -Be 'task-researcher.md'
}
It 'Strips .prompt.md suffix' {
$result = Get-PluginItemName -FileName 'gen-plan.prompt.md' -Kind 'prompt'
$result | Should -Be 'gen-plan.md'
}
It 'Strips .instructions.md suffix' {
$result = Get-PluginItemName -FileName 'csharp.instructions.md' -Kind 'instruction'
$result | Should -Be 'csharp.md'
}
It 'Returns skill directory name unchanged' {
$result = Get-PluginItemName -FileName 'video-to-gif' -Kind 'skill'
$result | Should -Be 'video-to-gif'
}
}
Describe 'Get-PluginSubdirectory' {
It 'Maps agent to agents' {
$result = Get-PluginSubdirectory -Kind 'agent'
$result | Should -Be 'agents'
}
It 'Maps prompt to commands' {
$result = Get-PluginSubdirectory -Kind 'prompt'
$result | Should -Be 'commands'
}
It 'Maps instruction to instructions' {
$result = Get-PluginSubdirectory -Kind 'instruction'
$result | Should -Be 'instructions'
}
It 'Maps skill to skills' {
$result = Get-PluginSubdirectory -Kind 'skill'
$result | Should -Be 'skills'
}
}microsoft/hve-core
Publicmirrored from https://github.com/microsoft/hve-coreAvailable
scripts/tests/plugins/PluginHelpers.Tests.ps1
167lines · modepreview