mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-09-04 19:25:36 +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
@@ -3,80 +3,25 @@
|
||||
.SYNOPSIS
|
||||
Pester 5 tests for Send-PveFile.
|
||||
All tests are fully offline — no live Proxmox VE target is required.
|
||||
If the cmdlet is not yet compiled the tests are marked Skipped.
|
||||
#>
|
||||
|
||||
BeforeAll {
|
||||
. $PSScriptRoot/../_TestHelper.ps1
|
||||
|
||||
$script:CmdExists = $null -ne (Get-Command 'Send-PveFile' -ErrorAction SilentlyContinue)
|
||||
}
|
||||
|
||||
Describe 'Send-PveFile' {
|
||||
|
||||
Context 'Manifest declaration' {
|
||||
It 'Should be declared in CmdletsToExport' {
|
||||
$manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1'
|
||||
if (-not (Test-Path $manifestPath)) { Set-ItResult -Skipped -Because 'Manifest not found'; return }
|
||||
$manifest = Import-PowerShellDataFile $manifestPath
|
||||
$manifest.CmdletsToExport | Should -Contain 'Send-PveFile'
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Command existence' {
|
||||
It 'Should be available after module import' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
(Get-Command 'Send-PveFile').CommandType | Should -Be 'Cmdlet'
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Required parameters' {
|
||||
BeforeAll {
|
||||
$script:Cmd = Get-Command 'Send-PveFile' -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
It 'Should have Node parameter (Mandatory)' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
$isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values |
|
||||
Where-Object { $_.IsMandatory }
|
||||
$isMandatory | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It 'Should have Storage parameter (Mandatory)' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
$isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values |
|
||||
Where-Object { $_.IsMandatory }
|
||||
$isMandatory | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It 'Should have Path parameter (Mandatory)' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
$isMandatory = $script:Cmd.Parameters['Path'].ParameterSets.Values |
|
||||
Where-Object { $_.IsMandatory }
|
||||
$isMandatory | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Context 'ChecksumAlgorithm ValidateSet' {
|
||||
BeforeAll {
|
||||
$script:Cmd = Get-Command 'Send-PveFile' -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
It 'Should have ChecksumAlgorithm parameter' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
$script:Cmd.Parameters.ContainsKey('ChecksumAlgorithm') | Should -BeTrue
|
||||
$script:Cmd = Get-Command 'Send-PveFile'
|
||||
}
|
||||
|
||||
It 'ChecksumAlgorithm should have a ValidateSet attribute' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
$validateSetAttr = $script:Cmd.Parameters['ChecksumAlgorithm'].Attributes |
|
||||
Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] }
|
||||
$validateSetAttr | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It 'ChecksumAlgorithm ValidateSet should include md5' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
$validateSetAttr = $script:Cmd.Parameters['ChecksumAlgorithm'].Attributes |
|
||||
Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } |
|
||||
Select-Object -First 1
|
||||
@@ -84,7 +29,6 @@ Describe 'Send-PveFile' {
|
||||
}
|
||||
|
||||
It 'ChecksumAlgorithm ValidateSet should include sha1' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
$validateSetAttr = $script:Cmd.Parameters['ChecksumAlgorithm'].Attributes |
|
||||
Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } |
|
||||
Select-Object -First 1
|
||||
@@ -92,7 +36,6 @@ Describe 'Send-PveFile' {
|
||||
}
|
||||
|
||||
It 'ChecksumAlgorithm ValidateSet should include sha256' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
$validateSetAttr = $script:Cmd.Parameters['ChecksumAlgorithm'].Attributes |
|
||||
Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } |
|
||||
Select-Object -First 1
|
||||
@@ -100,7 +43,6 @@ Describe 'Send-PveFile' {
|
||||
}
|
||||
|
||||
It 'ChecksumAlgorithm ValidateSet should include sha512' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
$validateSetAttr = $script:Cmd.Parameters['ChecksumAlgorithm'].Attributes |
|
||||
Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } |
|
||||
Select-Object -First 1
|
||||
@@ -110,16 +52,10 @@ Describe 'Send-PveFile' {
|
||||
|
||||
Context 'ContentType parameter' {
|
||||
BeforeAll {
|
||||
$script:Cmd = Get-Command 'Send-PveFile' -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
It 'Should have ContentType parameter' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
$script:Cmd.Parameters.ContainsKey('ContentType') | Should -BeTrue
|
||||
$script:Cmd = Get-Command 'Send-PveFile'
|
||||
}
|
||||
|
||||
It 'ContentType should have a ValidateSet attribute with iso, vztmpl, import' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
$validateSetAttr = $script:Cmd.Parameters['ContentType'].Attributes |
|
||||
Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] } |
|
||||
Select-Object -First 1
|
||||
@@ -131,37 +67,20 @@ Describe 'Send-PveFile' {
|
||||
|
||||
Context 'ShouldProcess support' {
|
||||
BeforeAll {
|
||||
$script:Cmd = Get-Command 'Send-PveFile' -ErrorAction SilentlyContinue
|
||||
$script:Cmd = Get-Command 'Send-PveFile'
|
||||
}
|
||||
|
||||
It 'Should support WhatIf' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Optional parameters' {
|
||||
BeforeAll {
|
||||
$script:Cmd = Get-Command 'Send-PveFile' -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
It 'Should have Checksum parameter' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
$script:Cmd.Parameters.ContainsKey('Checksum') | Should -BeTrue
|
||||
}
|
||||
|
||||
It 'Should have Session parameter' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
$script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue
|
||||
}
|
||||
|
||||
It 'Should have TimeoutSeconds parameter' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
$script:Cmd.Parameters.ContainsKey('TimeoutSeconds') | Should -BeTrue
|
||||
$script:Cmd = Get-Command 'Send-PveFile'
|
||||
}
|
||||
|
||||
It 'TimeoutSeconds should reject negative values' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
$tmpIso = [System.IO.Path]::GetTempFileName()
|
||||
try {
|
||||
{ Send-PveFile -Node 'n' -Storage 's' -Path $tmpIso -TimeoutSeconds -1 -Confirm:$false -ErrorAction Stop } |
|
||||
@@ -172,7 +91,6 @@ Describe 'Send-PveFile' {
|
||||
|
||||
Context 'Without active session' {
|
||||
It 'Should throw when no session is active (without -WhatIf)' {
|
||||
if (-not $script:CmdExists) { Set-ItResult -Skipped -Because 'Not yet compiled'; return }
|
||||
$tmpIso = [System.IO.Path]::GetTempFileName()
|
||||
try {
|
||||
{ Send-PveFile -Node 'pve-node1' -Storage 'local' -Path $tmpIso -Confirm:$false -ErrorAction Stop } |
|
||||
|
||||
Reference in New Issue
Block a user