refactor: make the offline Pester suite able to fail (#153) (#205)

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:
goodolclint-claude[bot]
2026-09-03 00:54:02 +00:00
committed by GitHub
parent 1f1c414632
commit 109dca657a
91 changed files with 9809 additions and 7330 deletions
@@ -5,90 +5,20 @@
Get-PveStorage, Get-PveStorageContent, New-PveStorage, Remove-PveStorage.
All tests are fully offline — no live Proxmox VE target is required.
If a cmdlet is not yet compiled the test is marked Skipped.
#>
BeforeAll {
. $PSScriptRoot/../_TestHelper.ps1
$script:Availability = @{}
foreach ($name in @('Get-PveStorage', 'Get-PveStorageContent',
'New-PveStorage', 'Remove-PveStorage')) {
$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 'Storage cmdlets — manifest declarations' {
It 'Get-PveStorage 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 'Get-PveStorage'
}
It 'Get-PveStorageContent 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 'Get-PveStorageContent'
}
}
# ---------------------------------------------------------------------------
# Get-PveStorage
# ---------------------------------------------------------------------------
Describe 'Get-PveStorage' {
BeforeAll { $script:Cmd = Get-Command 'Get-PveStorage' -ErrorAction SilentlyContinue }
Context 'Command existence' {
It 'Should be available after module import' {
Skip-IfMissing 'Get-PveStorage'
$script:Cmd | Should -Not -BeNullOrEmpty
}
It 'Should be a CmdletInfo (binary cmdlet)' {
Skip-IfMissing 'Get-PveStorage'
$script:Cmd.CommandType | Should -Be 'Cmdlet'
}
}
Context 'Parameter metadata' {
It 'Should have Node parameter' {
Skip-IfMissing 'Get-PveStorage'
$script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue
}
It 'Node should not be Mandatory (cluster-wide query when omitted)' {
Skip-IfMissing 'Get-PveStorage'
$isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -BeNullOrEmpty
}
It 'Should have Storage parameter (filter by name)' {
Skip-IfMissing 'Get-PveStorage'
$script:Cmd.Parameters.ContainsKey('Storage') | Should -BeTrue
}
It 'Should have Session parameter' {
Skip-IfMissing 'Get-PveStorage'
$script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue
}
}
BeforeAll { $script:Cmd = Get-Command 'Get-PveStorage' }
Context 'Without active session' {
It 'Should throw when no session is active' {
Skip-IfMissing 'Get-PveStorage'
{ Get-PveStorage -ErrorAction Stop } |
Should -Throw '*No active Proxmox VE session*'
}
@@ -99,36 +29,10 @@ Describe 'Get-PveStorage' {
# Get-PveStorageContent
# ---------------------------------------------------------------------------
Describe 'Get-PveStorageContent' {
BeforeAll { $script:Cmd = Get-Command 'Get-PveStorageContent' -ErrorAction SilentlyContinue }
Context 'Command existence' {
It 'Should be available after module import' {
Skip-IfMissing 'Get-PveStorageContent'
$script:Cmd | Should -Not -BeNullOrEmpty
}
}
Context 'Parameter metadata' {
It 'Node should be present' {
Skip-IfMissing 'Get-PveStorageContent'
$script:Cmd.Parameters.ContainsKey('Node') | Should -BeTrue
}
It 'Storage should be present' {
Skip-IfMissing 'Get-PveStorageContent'
$script:Cmd.Parameters.ContainsKey('Storage') | Should -BeTrue
}
It 'Should have Session parameter' {
Skip-IfMissing 'Get-PveStorageContent'
$script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue
}
}
BeforeAll { $script:Cmd = Get-Command 'Get-PveStorageContent' }
Context 'Without active session' {
It 'Should throw when no session is active' {
Skip-IfMissing 'Get-PveStorageContent'
{ Get-PveStorageContent -Node 'pve-node1' -Storage 'local' -ErrorAction Stop } |
Should -Throw '*No active Proxmox VE session*'
}
@@ -139,76 +43,16 @@ Describe 'Get-PveStorageContent' {
# New-PveStorage
# ---------------------------------------------------------------------------
Describe 'New-PveStorage' {
BeforeAll { $script:Cmd = Get-Command 'New-PveStorage' -ErrorAction SilentlyContinue }
Context 'Command existence' {
It 'Should be available after module import' {
Skip-IfMissing 'New-PveStorage'
$script:Cmd | Should -Not -BeNullOrEmpty
}
}
BeforeAll { $script:Cmd = Get-Command 'New-PveStorage' }
Context 'ShouldProcess support' {
It 'Should support WhatIf' {
Skip-IfMissing 'New-PveStorage'
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
}
}
Context 'Required parameters' {
It 'Storage (name) should be Mandatory' {
Skip-IfMissing 'New-PveStorage'
$isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
It 'Type should be Mandatory' {
Skip-IfMissing 'New-PveStorage'
$isMandatory = $script:Cmd.Parameters['Type'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
}
Context 'iSCSI/NFS parameters' {
It 'Should have Target parameter for iSCSI IQN' {
Skip-IfMissing 'New-PveStorage'
$script:Cmd.Parameters.ContainsKey('Target') | Should -BeTrue
}
It 'Target should not be Mandatory' {
Skip-IfMissing 'New-PveStorage'
$isMandatory = $script:Cmd.Parameters['Target'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -BeNullOrEmpty
}
It 'Should have Portal parameter for iSCSI portal' {
Skip-IfMissing 'New-PveStorage'
$script:Cmd.Parameters.ContainsKey('Portal') | Should -BeTrue
}
It 'Portal should not be Mandatory' {
Skip-IfMissing 'New-PveStorage'
$isMandatory = $script:Cmd.Parameters['Portal'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -BeNullOrEmpty
}
It 'Should have Server parameter for NFS/iSCSI server' {
Skip-IfMissing 'New-PveStorage'
$script:Cmd.Parameters.ContainsKey('Server') | Should -BeTrue
}
It 'Should have Export parameter for NFS export path' {
Skip-IfMissing 'New-PveStorage'
$script:Cmd.Parameters.ContainsKey('Export') | Should -BeTrue
}
It 'Should have Shared switch parameter' {
Skip-IfMissing 'New-PveStorage'
$script:Cmd.Parameters.ContainsKey('Shared') | Should -BeTrue
$script:Cmd.Parameters['Shared'].ParameterType | Should -Be ([System.Management.Automation.SwitchParameter])
}
@@ -219,37 +63,18 @@ Describe 'New-PveStorage' {
# Remove-PveStorage
# ---------------------------------------------------------------------------
Describe 'Remove-PveStorage' {
BeforeAll { $script:Cmd = Get-Command 'Remove-PveStorage' -ErrorAction SilentlyContinue }
Context 'Command existence' {
It 'Should be available after module import' {
Skip-IfMissing 'Remove-PveStorage'
$script:Cmd | Should -Not -BeNullOrEmpty
}
}
BeforeAll { $script:Cmd = Get-Command 'Remove-PveStorage' }
Context 'ShouldProcess / ConfirmImpact' {
It 'Should support WhatIf' {
Skip-IfMissing 'Remove-PveStorage'
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
}
It 'Should declare ConfirmImpact High' {
Skip-IfMissing 'Remove-PveStorage'
$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 'Storage should be Mandatory' {
Skip-IfMissing 'Remove-PveStorage'
$isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
}
}
@@ -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 } |
@@ -6,64 +6,26 @@
Set-PveStorageContent, New-PveStorageDisk.
All tests are fully offline — no live Proxmox VE target is required.
If a cmdlet is not yet compiled the test is marked Skipped.
#>
BeforeAll {
. $PSScriptRoot/../_TestHelper.ps1
$script:Availability = @{}
foreach ($name in @(
'Set-PveStorage', 'Get-PveStorageStatus', 'Remove-PveStorageContent',
'Set-PveStorageContent', 'New-PveStorageDisk'
)) {
$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"
}
}
}
# ---------------------------------------------------------------------------
# Set-PveStorage
# ---------------------------------------------------------------------------
Describe 'Set-PveStorage' -Tag 'Unit' {
BeforeAll { $script:Cmd = Get-Command 'Set-PveStorage' -ErrorAction SilentlyContinue }
Context 'Command existence' {
It 'Should be available after module import' {
Skip-IfMissing 'Set-PveStorage'
$script:Cmd | Should -Not -BeNullOrEmpty
}
It 'Should be a CmdletInfo (binary cmdlet)' {
Skip-IfMissing 'Set-PveStorage'
$script:Cmd.CommandType | Should -Be 'Cmdlet'
}
}
BeforeAll { $script:Cmd = Get-Command 'Set-PveStorage' }
Context 'ShouldProcess support' {
It 'Should support WhatIf' {
Skip-IfMissing 'Set-PveStorage'
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
}
}
Context 'Required parameters' {
It 'Storage should be Mandatory' {
Skip-IfMissing 'Set-PveStorage'
$isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
}
Context 'Without active session' {
It 'Should throw when no session is active' {
Skip-IfMissing 'Set-PveStorage'
{ Set-PveStorage -Storage 'local' -ErrorAction Stop } |
Should -Throw '*No active Proxmox VE session*'
}
@@ -74,38 +36,10 @@ Describe 'Set-PveStorage' -Tag 'Unit' {
# Get-PveStorageStatus
# ---------------------------------------------------------------------------
Describe 'Get-PveStorageStatus' -Tag 'Unit' {
BeforeAll { $script:Cmd = Get-Command 'Get-PveStorageStatus' -ErrorAction SilentlyContinue }
Context 'Command existence' {
It 'Should be available after module import' {
Skip-IfMissing 'Get-PveStorageStatus'
$script:Cmd | Should -Not -BeNullOrEmpty
}
It 'Should be a CmdletInfo (binary cmdlet)' {
Skip-IfMissing 'Get-PveStorageStatus'
$script:Cmd.CommandType | Should -Be 'Cmdlet'
}
}
Context 'Required parameters' {
It 'Node should be Mandatory' {
Skip-IfMissing 'Get-PveStorageStatus'
$isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
It 'Storage should be Mandatory' {
Skip-IfMissing 'Get-PveStorageStatus'
$isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
}
BeforeAll { $script:Cmd = Get-Command 'Get-PveStorageStatus' }
Context 'Without active session' {
It 'Should throw when no session is active' {
Skip-IfMissing 'Get-PveStorageStatus'
{ Get-PveStorageStatus -Node 'pve' -Storage 'local' -ErrorAction Stop } |
Should -Throw '*No active Proxmox VE session*'
}
@@ -116,23 +50,13 @@ Describe 'Get-PveStorageStatus' -Tag 'Unit' {
# Remove-PveStorageContent
# ---------------------------------------------------------------------------
Describe 'Remove-PveStorageContent' -Tag 'Unit' {
BeforeAll { $script:Cmd = Get-Command 'Remove-PveStorageContent' -ErrorAction SilentlyContinue }
Context 'Command existence' {
It 'Should be available after module import' {
Skip-IfMissing 'Remove-PveStorageContent'
$script:Cmd | Should -Not -BeNullOrEmpty
}
}
BeforeAll { $script:Cmd = Get-Command 'Remove-PveStorageContent' }
Context 'ShouldProcess / ConfirmImpact' {
It 'Should support WhatIf' {
Skip-IfMissing 'Remove-PveStorageContent'
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
}
It 'Should declare ConfirmImpact High' {
Skip-IfMissing 'Remove-PveStorageContent'
$attr = $script:Cmd.ImplementingType.GetCustomAttributes(
[System.Management.Automation.CmdletAttribute], $false) |
Select-Object -First 1
@@ -140,30 +64,8 @@ Describe 'Remove-PveStorageContent' -Tag 'Unit' {
}
}
Context 'Required parameters' {
It 'Node should be Mandatory' {
Skip-IfMissing 'Remove-PveStorageContent'
$isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
It 'Storage should be Mandatory' {
Skip-IfMissing 'Remove-PveStorageContent'
$isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
It 'Volume should be Mandatory' {
Skip-IfMissing 'Remove-PveStorageContent'
$isMandatory = $script:Cmd.Parameters['Volume'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
}
Context 'Without active session' {
It 'Should throw when no session is active' {
Skip-IfMissing 'Remove-PveStorageContent'
{ Remove-PveStorageContent -Node 'pve' -Storage 'local' -Volume 'local:iso/test.iso' -Confirm:$false -ErrorAction Stop } |
Should -Throw '*No active Proxmox VE session*'
}
@@ -174,51 +76,16 @@ Describe 'Remove-PveStorageContent' -Tag 'Unit' {
# Set-PveStorageContent
# ---------------------------------------------------------------------------
Describe 'Set-PveStorageContent' -Tag 'Unit' {
BeforeAll { $script:Cmd = Get-Command 'Set-PveStorageContent' -ErrorAction SilentlyContinue }
Context 'Command existence' {
It 'Should be available after module import' {
Skip-IfMissing 'Set-PveStorageContent'
$script:Cmd | Should -Not -BeNullOrEmpty
}
It 'Should be a CmdletInfo (binary cmdlet)' {
Skip-IfMissing 'Set-PveStorageContent'
$script:Cmd.CommandType | Should -Be 'Cmdlet'
}
}
BeforeAll { $script:Cmd = Get-Command 'Set-PveStorageContent' }
Context 'ShouldProcess support' {
It 'Should support WhatIf' {
Skip-IfMissing 'Set-PveStorageContent'
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
}
}
Context 'Required parameters' {
It 'Node should be Mandatory' {
Skip-IfMissing 'Set-PveStorageContent'
$isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
It 'Storage should be Mandatory' {
Skip-IfMissing 'Set-PveStorageContent'
$isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
It 'Volume should be Mandatory' {
Skip-IfMissing 'Set-PveStorageContent'
$isMandatory = $script:Cmd.Parameters['Volume'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
}
Context 'Without active session' {
It 'Should throw when no session is active' {
Skip-IfMissing 'Set-PveStorageContent'
{ Set-PveStorageContent -Node 'pve' -Storage 'local' -Volume 'local:iso/test.iso' -ErrorAction Stop } |
Should -Throw '*No active Proxmox VE session*'
}
@@ -229,57 +96,16 @@ Describe 'Set-PveStorageContent' -Tag 'Unit' {
# New-PveStorageDisk
# ---------------------------------------------------------------------------
Describe 'New-PveStorageDisk' -Tag 'Unit' {
BeforeAll { $script:Cmd = Get-Command 'New-PveStorageDisk' -ErrorAction SilentlyContinue }
Context 'Command existence' {
It 'Should be available after module import' {
Skip-IfMissing 'New-PveStorageDisk'
$script:Cmd | Should -Not -BeNullOrEmpty
}
It 'Should be a CmdletInfo (binary cmdlet)' {
Skip-IfMissing 'New-PveStorageDisk'
$script:Cmd.CommandType | Should -Be 'Cmdlet'
}
}
BeforeAll { $script:Cmd = Get-Command 'New-PveStorageDisk' }
Context 'ShouldProcess support' {
It 'Should support WhatIf' {
Skip-IfMissing 'New-PveStorageDisk'
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
}
}
Context 'Required parameters' {
It 'Node should be Mandatory' {
Skip-IfMissing 'New-PveStorageDisk'
$isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
It 'Storage should be Mandatory' {
Skip-IfMissing 'New-PveStorageDisk'
$isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
It 'Filename should be Mandatory' {
Skip-IfMissing 'New-PveStorageDisk'
$isMandatory = $script:Cmd.Parameters['Filename'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
It 'Size should be Mandatory' {
Skip-IfMissing 'New-PveStorageDisk'
$isMandatory = $script:Cmd.Parameters['Size'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
}
Context 'Without active session' {
It 'Should throw when no session is active' {
Skip-IfMissing 'New-PveStorageDisk'
{ New-PveStorageDisk -Node 'pve' -Storage 'local' -Filename 'vm-100-disk-1' -Size '32G' -ErrorAction Stop } |
Should -Throw '*No active Proxmox VE session*'
}
@@ -4,116 +4,48 @@
Pester 5 tests for Invoke-PveStorageDownload.
All tests are fully offline — no live Proxmox VE target is required.
If the cmdlet is not yet compiled the test is marked Skipped.
#>
BeforeAll {
. $PSScriptRoot/../_TestHelper.ps1
$script:CmdExists = $null -ne (Get-Command 'Invoke-PveStorageDownload' -ErrorAction SilentlyContinue)
function Skip-IfMissing([string]$Name) {
if (-not $script:CmdExists) {
Set-ItResult -Skipped -Because "$Name is not yet implemented in this build"
}
}
}
# ---------------------------------------------------------------------------
# Manifest contract
# ---------------------------------------------------------------------------
Describe 'Invoke-PveStorageDownload — 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 'Invoke-PveStorageDownload'
}
}
# ---------------------------------------------------------------------------
# Invoke-PveStorageDownload
# ---------------------------------------------------------------------------
Describe 'Invoke-PveStorageDownload' {
BeforeAll { $script:Cmd = Get-Command 'Invoke-PveStorageDownload' -ErrorAction SilentlyContinue }
Context 'Command existence' {
It 'Should be available after module import' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$script:Cmd | Should -Not -BeNullOrEmpty
}
It 'Should be a CmdletInfo (binary cmdlet)' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$script:Cmd.CommandType | Should -Be 'Cmdlet'
}
}
BeforeAll { $script:Cmd = Get-Command 'Invoke-PveStorageDownload' }
Context 'ShouldProcess support' {
It 'Should support WhatIf' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
}
It 'Should support Confirm' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$script:Cmd.Parameters.ContainsKey('Confirm') | Should -BeTrue
}
}
Context 'Required parameters' {
It 'Node should be Mandatory' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
It 'Node should be at Position 0' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$pos = $script:Cmd.Parameters['Node'].ParameterSets.Values |
ForEach-Object { $_.Position }
$pos | Should -Contain 0
}
It 'Storage should be Mandatory' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$isMandatory = $script:Cmd.Parameters['Storage'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
It 'Storage should be at Position 1' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$pos = $script:Cmd.Parameters['Storage'].ParameterSets.Values |
ForEach-Object { $_.Position }
$pos | Should -Contain 1
}
It 'Url should be Mandatory' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$isMandatory = $script:Cmd.Parameters['Url'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
It 'Url should be at Position 2' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$pos = $script:Cmd.Parameters['Url'].ParameterSets.Values |
ForEach-Object { $_.Position }
$pos | Should -Contain 2
}
It 'Filename should be Mandatory' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$isMandatory = $script:Cmd.Parameters['Filename'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
It 'Filename should be at Position 3' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$pos = $script:Cmd.Parameters['Filename'].ParameterSets.Values |
ForEach-Object { $_.Position }
$pos | Should -Contain 3
@@ -121,20 +53,7 @@ Describe 'Invoke-PveStorageDownload' {
}
Context 'Optional parameters' {
It 'Should have ContentType parameter' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$script:Cmd.Parameters.ContainsKey('ContentType') | Should -BeTrue
}
It 'ContentType should not be Mandatory' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$isMandatory = $script:Cmd.Parameters['ContentType'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -BeNullOrEmpty
}
It 'ContentType should have a ValidateSet of iso, vztmpl, backup, import' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$validateSet = $script:Cmd.Parameters['ContentType'].Attributes |
Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] }
$validateSet | Should -Not -BeNullOrEmpty
@@ -146,33 +65,18 @@ Describe 'Invoke-PveStorageDownload' {
}
It 'Should have Wait switch parameter' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$script:Cmd.Parameters.ContainsKey('Wait') | Should -BeTrue
$script:Cmd.Parameters['Wait'].SwitchParameter | Should -BeTrue
}
It 'Should have TimeoutSeconds parameter' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$script:Cmd.Parameters.ContainsKey('TimeoutSeconds') | Should -BeTrue
}
It 'TimeoutSeconds should reject negative values' {
Skip-IfMissing 'Invoke-PveStorageDownload'
{ Invoke-PveStorageDownload -Node 'pve1' -Storage 'local' -Url 'https://example.com/test.iso' -Filename 'test.iso' -TimeoutSeconds -1 -Confirm:$false -ErrorAction Stop } |
Should -Throw
}
}
Context 'Session parameter' {
It 'Should have Session parameter (inherited from PveCmdletBase)' {
Skip-IfMissing 'Invoke-PveStorageDownload'
$script:Cmd.Parameters.ContainsKey('Session') | Should -BeTrue
}
}
Context 'Without active session' {
It 'Should throw when no session is active' {
Skip-IfMissing 'Invoke-PveStorageDownload'
{ Invoke-PveStorageDownload -Node 'pve1' -Storage 'local' -Url 'https://example.com/test.iso' -Filename 'test.iso' -Confirm:$false -ErrorAction Stop } |
Should -Throw '*No active Proxmox VE session*'
}