mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-09-04 03:05:32 +00:00
109dca657a
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>
128 lines
4.6 KiB
PowerShell
128 lines
4.6 KiB
PowerShell
#Requires -Module Pester
|
|
<#
|
|
.SYNOPSIS
|
|
Pester 5 tests for SDN cmdlets:
|
|
Get-PveSdnZone, New-PveSdnZone, Remove-PveSdnZone,
|
|
Get-PveSdnVnet, New-PveSdnVnet, Remove-PveSdnVnet.
|
|
|
|
All tests are fully offline — no live Proxmox VE target is required.
|
|
|
|
SDN support was introduced in Proxmox VE 7 and became stable in PVE 8.
|
|
These cmdlets should include a version guard that raises PveVersionException
|
|
(or similar) when the server version is below the minimum requirement.
|
|
The version guard tests use fully-mocked sessions (no network calls).
|
|
#>
|
|
|
|
BeforeAll {
|
|
. $PSScriptRoot/../_TestHelper.ps1
|
|
|
|
$script:SdnCmdlets = @(
|
|
'Get-PveSdnZone', 'New-PveSdnZone', 'Remove-PveSdnZone',
|
|
'Get-PveSdnVnet', 'New-PveSdnVnet', 'Remove-PveSdnVnet'
|
|
)
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Get-PveSdnZone
|
|
# ---------------------------------------------------------------------------
|
|
Describe 'Get-PveSdnZone' {
|
|
BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnZone' }
|
|
|
|
Context 'Version guard behaviour — without active session' {
|
|
It 'Should throw when no session is active' {
|
|
{ Get-PveSdnZone -ErrorAction Stop } |
|
|
Should -Throw '*No active Proxmox VE session*'
|
|
}
|
|
}
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# New-PveSdnZone
|
|
# ---------------------------------------------------------------------------
|
|
Describe 'New-PveSdnZone' {
|
|
BeforeAll { $script:Cmd = Get-Command 'New-PveSdnZone' }
|
|
|
|
Context 'ShouldProcess support' {
|
|
It 'Should support WhatIf' {
|
|
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
|
|
}
|
|
}
|
|
|
|
Context 'Type ValidateSet' {
|
|
It 'Type parameter should have ValidateSet including known zone types' {
|
|
$validateSetAttr = $script:Cmd.Parameters['Type'].Attributes |
|
|
Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } |
|
|
Select-Object -First 1
|
|
$validateSetAttr | Should -Not -BeNullOrEmpty
|
|
$validateSetAttr.ValidValues | Should -Contain 'simple'
|
|
}
|
|
}
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Remove-PveSdnZone
|
|
# ---------------------------------------------------------------------------
|
|
Describe 'Remove-PveSdnZone' {
|
|
BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnZone' }
|
|
|
|
Context 'ShouldProcess / ConfirmImpact' {
|
|
It 'Should support WhatIf' {
|
|
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
|
|
}
|
|
|
|
It 'Should declare ConfirmImpact High' {
|
|
$attr = $script:Cmd.ImplementingType.GetCustomAttributes(
|
|
[System.Management.Automation.CmdletAttribute], $false) |
|
|
Select-Object -First 1
|
|
$attr.ConfirmImpact | Should -Be ([System.Management.Automation.ConfirmImpact]::High)
|
|
}
|
|
}
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Get-PveSdnVnet
|
|
# ---------------------------------------------------------------------------
|
|
Describe 'Get-PveSdnVnet' {
|
|
BeforeAll { $script:Cmd = Get-Command 'Get-PveSdnVnet' }
|
|
|
|
Context 'Without active session' {
|
|
It 'Should throw when no session is active' {
|
|
{ Get-PveSdnVnet -ErrorAction Stop } |
|
|
Should -Throw '*No active Proxmox VE session*'
|
|
}
|
|
}
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# New-PveSdnVnet
|
|
# ---------------------------------------------------------------------------
|
|
Describe 'New-PveSdnVnet' {
|
|
BeforeAll { $script:Cmd = Get-Command 'New-PveSdnVnet' }
|
|
|
|
Context 'ShouldProcess support' {
|
|
It 'Should support WhatIf' {
|
|
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
|
|
}
|
|
}
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Remove-PveSdnVnet
|
|
# ---------------------------------------------------------------------------
|
|
Describe 'Remove-PveSdnVnet' {
|
|
BeforeAll { $script:Cmd = Get-Command 'Remove-PveSdnVnet' }
|
|
|
|
Context 'ShouldProcess / ConfirmImpact' {
|
|
It 'Should support WhatIf' {
|
|
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
|
|
}
|
|
|
|
It 'Should declare ConfirmImpact High' {
|
|
$attr = $script:Cmd.ImplementingType.GetCustomAttributes(
|
|
[System.Management.Automation.CmdletAttribute], $false) |
|
|
Select-Object -First 1
|
|
$attr.ConfirmImpact | Should -Be ([System.Management.Automation.ConfirmImpact]::High)
|
|
}
|
|
}
|
|
}
|