#Requires -Module Pester <# .SYNOPSIS Pester 5 tests for container gap cmdlets: Suspend-PveContainer, Resume-PveContainer, Resize-PveContainerDisk, New-PveContainerTemplate, Move-PveContainerVolume, Get-PveContainerInterface. 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 @( 'Suspend-PveContainer', 'Resume-PveContainer', 'Resize-PveContainerDisk', 'New-PveContainerTemplate', 'Move-PveContainerVolume', 'Get-PveContainerInterface' )) { $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" } } } # --------------------------------------------------------------------------- # Suspend-PveContainer # --------------------------------------------------------------------------- Describe 'Suspend-PveContainer' -Tag 'Unit' { BeforeAll { $script:Cmd = Get-Command 'Suspend-PveContainer' -ErrorAction SilentlyContinue } Context 'Command existence' { It 'Should be available after module import' { Skip-IfMissing 'Suspend-PveContainer' $script:Cmd | Should -Not -BeNullOrEmpty } It 'Should be a CmdletInfo (binary cmdlet)' { Skip-IfMissing 'Suspend-PveContainer' $script:Cmd.CommandType | Should -Be 'Cmdlet' } } Context 'ShouldProcess support' { It 'Should support WhatIf' { Skip-IfMissing 'Suspend-PveContainer' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } Context 'Required parameters' { It 'Node should be Mandatory' { Skip-IfMissing 'Suspend-PveContainer' $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | Where-Object { $_.IsMandatory } $isMandatory | Should -Not -BeNullOrEmpty } It 'VmId should be Mandatory' { Skip-IfMissing 'Suspend-PveContainer' $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | Where-Object { $_.IsMandatory } $isMandatory | Should -Not -BeNullOrEmpty } } Context 'Without active session' { It 'Should throw when no session is active' { Skip-IfMissing 'Suspend-PveContainer' { Suspend-PveContainer -Node 'pve' -VmId 100 -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } } } # --------------------------------------------------------------------------- # Resume-PveContainer # --------------------------------------------------------------------------- Describe 'Resume-PveContainer' -Tag 'Unit' { BeforeAll { $script:Cmd = Get-Command 'Resume-PveContainer' -ErrorAction SilentlyContinue } Context 'Command existence' { It 'Should be available after module import' { Skip-IfMissing 'Resume-PveContainer' $script:Cmd | Should -Not -BeNullOrEmpty } It 'Should be a CmdletInfo (binary cmdlet)' { Skip-IfMissing 'Resume-PveContainer' $script:Cmd.CommandType | Should -Be 'Cmdlet' } } Context 'ShouldProcess support' { It 'Should support WhatIf' { Skip-IfMissing 'Resume-PveContainer' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } Context 'Required parameters' { It 'Node should be Mandatory' { Skip-IfMissing 'Resume-PveContainer' $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | Where-Object { $_.IsMandatory } $isMandatory | Should -Not -BeNullOrEmpty } It 'VmId should be Mandatory' { Skip-IfMissing 'Resume-PveContainer' $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | Where-Object { $_.IsMandatory } $isMandatory | Should -Not -BeNullOrEmpty } } Context 'Without active session' { It 'Should throw when no session is active' { Skip-IfMissing 'Resume-PveContainer' { Resume-PveContainer -Node 'pve' -VmId 100 -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } } } # --------------------------------------------------------------------------- # Resize-PveContainerDisk # --------------------------------------------------------------------------- Describe 'Resize-PveContainerDisk' -Tag 'Unit' { BeforeAll { $script:Cmd = Get-Command 'Resize-PveContainerDisk' -ErrorAction SilentlyContinue } Context 'Command existence' { It 'Should be available after module import' { Skip-IfMissing 'Resize-PveContainerDisk' $script:Cmd | Should -Not -BeNullOrEmpty } It 'Should be a CmdletInfo (binary cmdlet)' { Skip-IfMissing 'Resize-PveContainerDisk' $script:Cmd.CommandType | Should -Be 'Cmdlet' } } Context 'ShouldProcess support' { It 'Should support WhatIf' { Skip-IfMissing 'Resize-PveContainerDisk' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } Context 'Required parameters' { It 'Node should be Mandatory' { Skip-IfMissing 'Resize-PveContainerDisk' $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | Where-Object { $_.IsMandatory } $isMandatory | Should -Not -BeNullOrEmpty } It 'VmId should be Mandatory' { Skip-IfMissing 'Resize-PveContainerDisk' $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | Where-Object { $_.IsMandatory } $isMandatory | Should -Not -BeNullOrEmpty } It 'Disk should be Mandatory' { Skip-IfMissing 'Resize-PveContainerDisk' $isMandatory = $script:Cmd.Parameters['Disk'].ParameterSets.Values | Where-Object { $_.IsMandatory } $isMandatory | Should -Not -BeNullOrEmpty } It 'Size should be Mandatory' { Skip-IfMissing 'Resize-PveContainerDisk' $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 'Resize-PveContainerDisk' { Resize-PveContainerDisk -Node 'pve' -VmId 100 -Disk 'rootfs' -Size '+5G' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } } } # --------------------------------------------------------------------------- # New-PveContainerTemplate # --------------------------------------------------------------------------- Describe 'New-PveContainerTemplate' -Tag 'Unit' { BeforeAll { $script:Cmd = Get-Command 'New-PveContainerTemplate' -ErrorAction SilentlyContinue } Context 'Command existence' { It 'Should be available after module import' { Skip-IfMissing 'New-PveContainerTemplate' $script:Cmd | Should -Not -BeNullOrEmpty } } Context 'ShouldProcess / ConfirmImpact' { It 'Should support WhatIf' { Skip-IfMissing 'New-PveContainerTemplate' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } It 'Should declare ConfirmImpact High' { Skip-IfMissing 'New-PveContainerTemplate' $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 'Node should be Mandatory' { Skip-IfMissing 'New-PveContainerTemplate' $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | Where-Object { $_.IsMandatory } $isMandatory | Should -Not -BeNullOrEmpty } It 'VmId should be Mandatory' { Skip-IfMissing 'New-PveContainerTemplate' $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | Where-Object { $_.IsMandatory } $isMandatory | Should -Not -BeNullOrEmpty } } Context 'Without active session' { It 'Should throw when no session is active' { Skip-IfMissing 'New-PveContainerTemplate' { New-PveContainerTemplate -Node 'pve' -VmId 100 -Confirm:$false -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } } } # --------------------------------------------------------------------------- # Move-PveContainerVolume # --------------------------------------------------------------------------- Describe 'Move-PveContainerVolume' -Tag 'Unit' { BeforeAll { $script:Cmd = Get-Command 'Move-PveContainerVolume' -ErrorAction SilentlyContinue } Context 'Command existence' { It 'Should be available after module import' { Skip-IfMissing 'Move-PveContainerVolume' $script:Cmd | Should -Not -BeNullOrEmpty } It 'Should be a CmdletInfo (binary cmdlet)' { Skip-IfMissing 'Move-PveContainerVolume' $script:Cmd.CommandType | Should -Be 'Cmdlet' } } Context 'ShouldProcess support' { It 'Should support WhatIf' { Skip-IfMissing 'Move-PveContainerVolume' $script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue } } Context 'Required parameters' { It 'Node should be Mandatory' { Skip-IfMissing 'Move-PveContainerVolume' $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | Where-Object { $_.IsMandatory } $isMandatory | Should -Not -BeNullOrEmpty } It 'VmId should be Mandatory' { Skip-IfMissing 'Move-PveContainerVolume' $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | Where-Object { $_.IsMandatory } $isMandatory | Should -Not -BeNullOrEmpty } It 'Volume should be Mandatory' { Skip-IfMissing 'Move-PveContainerVolume' $isMandatory = $script:Cmd.Parameters['Volume'].ParameterSets.Values | Where-Object { $_.IsMandatory } $isMandatory | Should -Not -BeNullOrEmpty } It 'Storage should be Mandatory' { Skip-IfMissing 'Move-PveContainerVolume' $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 'Move-PveContainerVolume' { Move-PveContainerVolume -Node 'pve' -VmId 100 -Volume 'rootfs' -Storage 'local-lvm' -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } } } # --------------------------------------------------------------------------- # Get-PveContainerInterface # --------------------------------------------------------------------------- Describe 'Get-PveContainerInterface' -Tag 'Unit' { BeforeAll { $script:Cmd = Get-Command 'Get-PveContainerInterface' -ErrorAction SilentlyContinue } Context 'Command existence' { It 'Should be available after module import' { Skip-IfMissing 'Get-PveContainerInterface' $script:Cmd | Should -Not -BeNullOrEmpty } It 'Should be a CmdletInfo (binary cmdlet)' { Skip-IfMissing 'Get-PveContainerInterface' $script:Cmd.CommandType | Should -Be 'Cmdlet' } } Context 'Required parameters' { It 'Node should be Mandatory' { Skip-IfMissing 'Get-PveContainerInterface' $isMandatory = $script:Cmd.Parameters['Node'].ParameterSets.Values | Where-Object { $_.IsMandatory } $isMandatory | Should -Not -BeNullOrEmpty } It 'VmId should be Mandatory' { Skip-IfMissing 'Get-PveContainerInterface' $isMandatory = $script:Cmd.Parameters['VmId'].ParameterSets.Values | Where-Object { $_.IsMandatory } $isMandatory | Should -Not -BeNullOrEmpty } } Context 'Without active session' { It 'Should throw when no session is active' { Skip-IfMissing 'Get-PveContainerInterface' { Get-PveContainerInterface -Node 'pve' -VmId 100 -ErrorAction Stop } | Should -Throw '*No active Proxmox VE session*' } } }