mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-09-04 11:15:34 +00:00
Skip-IfMissing skipped a test whenever the cmdlet under test was absent from the build, including the test asserting it exists. Every cmdlet compiles into one assembly, so there is no partial-build case for it to serve; all it did was hide a missing cmdlet. Delete the 37 copies and every call site, and drop the residual conditional skips in the same family (CmdExists probes, an attribute-presence skip in SdnCmdlets, a lifecycle helper skipping on a cmdlet-name collision fixed long ago). 894 It blocks only reflected [Cmdlet] and [Parameter] attributes back at the compiler: existence, CommandType -eq 'Cmdlet', Parameters.ContainsKey, IsMandatory reflection, and per-file CmdletsToExport asserts for whichever names an author remembered. Nothing reflected over the built assembly, so a new cmdlet missing from the manifest shipped invisible. One data-driven file replaces them: it diffs CmdletsToExport against the assembly's cmdlet types in both directions and asserts the conventions reflection can see. Behavioural tests are untouched: no-session errors, binding rejections, ShouldProcess and -WhatIf, ConfirmImpact, ValidateSet and ValidateRange values, parameter types, positions and pipeline binding. The generated help covered 169 of 194 cmdlets. Regenerated with the repo's own generate-help.ps1: 25 new markdown stubs, 13 existing docs picking up parameters added in earlier waves, and a rebuilt MAML. Co-authored-by: goodolclint-claude[bot] <323206664+goodolclint-claude[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
1f1c414632
commit
109dca657a
@@ -20,75 +20,16 @@ BeforeAll {
|
||||
'Get-PveSdnZone', 'New-PveSdnZone', 'Remove-PveSdnZone',
|
||||
'Get-PveSdnVnet', 'New-PveSdnVnet', 'Remove-PveSdnVnet'
|
||||
)
|
||||
|
||||
$script:Availability = @{}
|
||||
foreach ($name in $script:SdnCmdlets) {
|
||||
$script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue)
|
||||
}
|
||||
|
||||
function Skip-IfMissing([string]$Name) {
|
||||
if (-not $script:Availability[$Name]) {
|
||||
Set-ItResult -Skipped -Because "$Name is not yet implemented in this build"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Manifest contract
|
||||
# ---------------------------------------------------------------------------
|
||||
Describe 'SDN cmdlets — manifest declarations' {
|
||||
BeforeAll {
|
||||
$manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1'
|
||||
$script:Manifest = if (Test-Path $manifestPath) { Import-PowerShellDataFile $manifestPath } else { $null }
|
||||
}
|
||||
|
||||
It "<cmdName> should be declared in CmdletsToExport" -TestCases @(
|
||||
@{ cmdName = 'Get-PveSdnZone' }
|
||||
@{ cmdName = 'New-PveSdnZone' }
|
||||
@{ cmdName = 'Remove-PveSdnZone' }
|
||||
@{ cmdName = 'Get-PveSdnVnet' }
|
||||
@{ cmdName = 'New-PveSdnVnet' }
|
||||
@{ cmdName = 'Remove-PveSdnVnet' }
|
||||
) {
|
||||
if ($null -eq $script:Manifest) { Set-ItResult -Skipped -Because 'Manifest not found'; return }
|
||||
$script:Manifest.CmdletsToExport | Should -Contain $cmdName
|
||||
}
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Get-PveSdnZone
|
||||
# ---------------------------------------------------------------------------
|
||||
Describe 'Get-PveSdnZone' {
|
||||
|
||||
BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnZone' -ErrorAction SilentlyContinue }
|
||||
|
||||
Context 'Command existence' {
|
||||
It 'Should be available after module import' {
|
||||
Skip-IfMissing 'Get-PveSdnZone'
|
||||
$script:Cmd | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It 'Should be a CmdletInfo (binary cmdlet)' {
|
||||
Skip-IfMissing 'Get-PveSdnZone'
|
||||
$script:Cmd.CommandType | Should -Be 'Cmdlet'
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Parameter metadata' {
|
||||
It 'Should have Zone parameter (optional filter by zone ID)' {
|
||||
Skip-IfMissing 'Get-PveSdnZone'
|
||||
$script:Cmd.Parameters.ContainsKey('Zone') | Should -BeTrue
|
||||
}
|
||||
|
||||
It 'Should have Session parameter' {
|
||||
Skip-IfMissing 'Get-PveSdnZone'
|
||||
$script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue
|
||||
}
|
||||
}
|
||||
BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnZone' }
|
||||
|
||||
Context 'Version guard behaviour — without active session' {
|
||||
It 'Should throw when no session is active' {
|
||||
Skip-IfMissing 'Get-PveSdnZone'
|
||||
{ Get-PveSdnZone -ErrorAction Stop } |
|
||||
Should -Throw '*No active Proxmox VE session*'
|
||||
}
|
||||
@@ -99,51 +40,21 @@ Describe 'Get-PveSdnZone' {
|
||||
# New-PveSdnZone
|
||||
# ---------------------------------------------------------------------------
|
||||
Describe 'New-PveSdnZone' {
|
||||
|
||||
BeforeAll { $script:Cmd = Get-Command 'New-PveSdnZone' -ErrorAction SilentlyContinue }
|
||||
|
||||
Context 'Command existence' {
|
||||
It 'Should be available after module import' {
|
||||
Skip-IfMissing 'New-PveSdnZone'
|
||||
$script:Cmd | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
BeforeAll { $script:Cmd = Get-Command 'New-PveSdnZone' }
|
||||
|
||||
Context 'ShouldProcess support' {
|
||||
It 'Should support WhatIf' {
|
||||
Skip-IfMissing 'New-PveSdnZone'
|
||||
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Required parameters' {
|
||||
It 'Zone should be Mandatory' {
|
||||
Skip-IfMissing 'New-PveSdnZone'
|
||||
$isMandatory = $script:Cmd.Parameters['Zone'].ParameterSets.Values |
|
||||
Where-Object { $_.IsMandatory }
|
||||
$isMandatory | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It 'Type should be Mandatory' {
|
||||
Skip-IfMissing 'New-PveSdnZone'
|
||||
$isMandatory = $script:Cmd.Parameters['Type'].ParameterSets.Values |
|
||||
Where-Object { $_.IsMandatory }
|
||||
$isMandatory | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Type ValidateSet' {
|
||||
It 'Type parameter should have ValidateSet including known zone types' {
|
||||
Skip-IfMissing 'New-PveSdnZone'
|
||||
$validateSetAttr = $script:Cmd.Parameters['Type'].Attributes |
|
||||
Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } |
|
||||
Select-Object -First 1
|
||||
if ($null -ne $validateSetAttr) {
|
||||
$validateSetAttr.ValidValues | Should -Contain 'simple'
|
||||
}
|
||||
else {
|
||||
Set-ItResult -Skipped -Because 'Type does not use a ValidateSet attribute in this build'
|
||||
}
|
||||
$validateSetAttr | Should -Not -BeNullOrEmpty
|
||||
$validateSetAttr.ValidValues | Should -Contain 'simple'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,75 +63,30 @@ Describe 'New-PveSdnZone' {
|
||||
# Remove-PveSdnZone
|
||||
# ---------------------------------------------------------------------------
|
||||
Describe 'Remove-PveSdnZone' {
|
||||
|
||||
BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnZone' -ErrorAction SilentlyContinue }
|
||||
|
||||
Context 'Command existence' {
|
||||
It 'Should be available after module import' {
|
||||
Skip-IfMissing 'Remove-PveSdnZone'
|
||||
$script:Cmd | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnZone' }
|
||||
|
||||
Context 'ShouldProcess / ConfirmImpact' {
|
||||
It 'Should support WhatIf' {
|
||||
Skip-IfMissing 'Remove-PveSdnZone'
|
||||
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
|
||||
}
|
||||
|
||||
It 'Should declare ConfirmImpact High' {
|
||||
Skip-IfMissing 'Remove-PveSdnZone'
|
||||
$attr = $script:Cmd.ImplementingType.GetCustomAttributes(
|
||||
[System.Management.Automation.CmdletAttribute], $false) |
|
||||
Select-Object -First 1
|
||||
$attr.ConfirmImpact | Should -Be ([System.Management.Automation.ConfirmImpact]::High)
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Required parameters' {
|
||||
It 'Zone should be Mandatory' {
|
||||
Skip-IfMissing 'Remove-PveSdnZone'
|
||||
$isMandatory = $script:Cmd.Parameters['Zone'].ParameterSets.Values |
|
||||
Where-Object { $_.IsMandatory }
|
||||
$isMandatory | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Get-PveSdnVnet
|
||||
# ---------------------------------------------------------------------------
|
||||
Describe 'Get-PveSdnVnet' {
|
||||
|
||||
BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnVnet' -ErrorAction SilentlyContinue }
|
||||
|
||||
Context 'Command existence' {
|
||||
It 'Should be available after module import' {
|
||||
Skip-IfMissing 'Get-PveSdnVnet'
|
||||
$script:Cmd | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Parameter metadata' {
|
||||
It 'Should have Vnet parameter (optional filter by VNet name)' {
|
||||
Skip-IfMissing 'Get-PveSdnVnet'
|
||||
$script:Cmd.Parameters.ContainsKey('Vnet') | Should -BeTrue
|
||||
}
|
||||
|
||||
It 'Should have Zone parameter (optional filter by parent zone)' {
|
||||
Skip-IfMissing 'Get-PveSdnVnet'
|
||||
$script:Cmd.Parameters.ContainsKey('Zone') | Should -BeTrue
|
||||
}
|
||||
|
||||
It 'Should have Session parameter' {
|
||||
Skip-IfMissing 'Get-PveSdnVnet'
|
||||
$script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue
|
||||
}
|
||||
}
|
||||
BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnVnet' }
|
||||
|
||||
Context 'Without active session' {
|
||||
It 'Should throw when no session is active' {
|
||||
Skip-IfMissing 'Get-PveSdnVnet'
|
||||
{ Get-PveSdnVnet -ErrorAction Stop } |
|
||||
Should -Throw '*No active Proxmox VE session*'
|
||||
}
|
||||
@@ -231,75 +97,31 @@ Describe 'Get-PveSdnVnet' {
|
||||
# New-PveSdnVnet
|
||||
# ---------------------------------------------------------------------------
|
||||
Describe 'New-PveSdnVnet' {
|
||||
|
||||
BeforeAll { $script:Cmd = Get-Command 'New-PveSdnVnet' -ErrorAction SilentlyContinue }
|
||||
|
||||
Context 'Command existence' {
|
||||
It 'Should be available after module import' {
|
||||
Skip-IfMissing 'New-PveSdnVnet'
|
||||
$script:Cmd | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
BeforeAll { $script:Cmd = Get-Command 'New-PveSdnVnet' }
|
||||
|
||||
Context 'ShouldProcess support' {
|
||||
It 'Should support WhatIf' {
|
||||
Skip-IfMissing 'New-PveSdnVnet'
|
||||
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Required parameters' {
|
||||
It 'Vnet should be Mandatory' {
|
||||
Skip-IfMissing 'New-PveSdnVnet'
|
||||
$isMandatory = $script:Cmd.Parameters['Vnet'].ParameterSets.Values |
|
||||
Where-Object { $_.IsMandatory }
|
||||
$isMandatory | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It 'Zone should be Mandatory' {
|
||||
Skip-IfMissing 'New-PveSdnVnet'
|
||||
$isMandatory = $script:Cmd.Parameters['Zone'].ParameterSets.Values |
|
||||
Where-Object { $_.IsMandatory }
|
||||
$isMandatory | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Remove-PveSdnVnet
|
||||
# ---------------------------------------------------------------------------
|
||||
Describe 'Remove-PveSdnVnet' {
|
||||
|
||||
BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnVnet' -ErrorAction SilentlyContinue }
|
||||
|
||||
Context 'Command existence' {
|
||||
It 'Should be available after module import' {
|
||||
Skip-IfMissing 'Remove-PveSdnVnet'
|
||||
$script:Cmd | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnVnet' }
|
||||
|
||||
Context 'ShouldProcess / ConfirmImpact' {
|
||||
It 'Should support WhatIf' {
|
||||
Skip-IfMissing 'Remove-PveSdnVnet'
|
||||
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
|
||||
}
|
||||
|
||||
It 'Should declare ConfirmImpact High' {
|
||||
Skip-IfMissing 'Remove-PveSdnVnet'
|
||||
$attr = $script:Cmd.ImplementingType.GetCustomAttributes(
|
||||
[System.Management.Automation.CmdletAttribute], $false) |
|
||||
Select-Object -First 1
|
||||
$attr.ConfirmImpact | Should -Be ([System.Management.Automation.ConfirmImpact]::High)
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Required parameters' {
|
||||
It 'Vnet should be Mandatory' {
|
||||
Skip-IfMissing 'Remove-PveSdnVnet'
|
||||
$isMandatory = $script:Cmd.Parameters['Vnet'].ParameterSets.Values |
|
||||
Where-Object { $_.IsMandatory }
|
||||
$isMandatory | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user