chore(test): update tests for parameter changes, target net10.0

- xUnit test project now targets net10.0 instead of net9.0 (EOL Nov 2026)
- Updated GuestAgentExtCmdlets tests for SecureString Password parameter
- Added Timeout parameter tests to GuestAgentCmdlets
- Added ConfirmImpact.High assertions for Suspend/Restart-PveVm
- Added -Confirm:$false to Suspend-PveVm integration test call

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Clint Branham
2026-03-22 08:16:45 -05:00
parent 887429a729
commit d99c3e5490
5 changed files with 43 additions and 5 deletions
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net9.0;net48</TargetFrameworks>
<TargetFrameworks>net10.0;net48</TargetFrameworks>
<LangVersion>10.0</LangVersion>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
@@ -1210,7 +1210,7 @@ Describe 'Integration Tests' -Tag 'Integration' {
if (Skip-IfNoLinuxVm) { return }
# Suspend — -Wait -Timeout polls qmpstatus until 'paused'
$suspendTask = Suspend-PveVm -Node $script:Node -VmId $script:LinuxVmId -Wait -Timeout 30
$suspendTask = Suspend-PveVm -Node $script:Node -VmId $script:LinuxVmId -Wait -Timeout 30 -Confirm:$false
$suspendTask | Should -Not -BeNullOrEmpty
# Verify with -Detailed (fetches qmpstatus from status/current endpoint)
@@ -202,6 +202,21 @@ Describe 'Invoke-PveVmGuestExec' {
Where-Object { $_.IsMandatory }
$isMandatory | Should -Not -BeNullOrEmpty
}
It 'Should have Timeout parameter of type int' {
Skip-IfMissing 'Invoke-PveVmGuestExec'
$script:Cmd.Parameters.ContainsKey('Timeout') | Should -BeTrue
$script:Cmd.Parameters['Timeout'].ParameterType | Should -Be ([int])
}
It 'Timeout should have ValidateRange(1,3600)' {
Skip-IfMissing 'Invoke-PveVmGuestExec'
$rangeAttr = $script:Cmd.Parameters['Timeout'].Attributes |
Where-Object { $_ -is [System.Management.Automation.ValidateRangeAttribute] }
$rangeAttr | Should -Not -BeNullOrEmpty
$rangeAttr.MinRange | Should -Be 1
$rangeAttr.MaxRange | Should -Be 3600
}
}
Context 'Without active session' {
@@ -272,10 +272,19 @@ Describe 'Set-PveVmGuestPassword' -Tag 'Unit' {
}
}
Context 'Parameter types' {
It 'Password should be SecureString' {
Skip-IfMissing 'Set-PveVmGuestPassword'
$script:Cmd.Parameters['Password'].ParameterType |
Should -Be ([System.Security.SecureString])
}
}
Context 'Without active session' {
It 'Should throw when no session is active' {
Skip-IfMissing 'Set-PveVmGuestPassword'
{ Set-PveVmGuestPassword -Node 'pve' -VmId 100 -Username 'root' -Password 'dummy' -ErrorAction Stop } |
$secPwd = ConvertTo-SecureString 'dummy' -AsPlainText -Force
{ Set-PveVmGuestPassword -Node 'pve' -VmId 100 -Username 'root' -Password $secPwd -ErrorAction Stop } |
Should -Throw '*No active Proxmox VE session*'
}
}
@@ -165,11 +165,18 @@ Describe 'Suspend-PveVm' {
It 'Should support ShouldProcess' {
$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)
}
}
Context 'Without active session' {
It 'Should throw when no session is active (without -WhatIf)' {
{ Suspend-PveVm -Node 'pve-node1' -VmId 100 -ErrorAction Stop } |
{ Suspend-PveVm -Node 'pve-node1' -VmId 100 -Confirm:$false -ErrorAction Stop } |
Should -Throw '*No active Proxmox VE session*'
}
}
@@ -303,11 +310,18 @@ Describe 'Restart-PveVm' {
It 'Should support ShouldProcess' {
$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)
}
}
Context 'Without active session' {
It 'Should throw when no session is active (without -WhatIf)' {
{ Restart-PveVm -Node 'pve-node1' -VmId 100 -ErrorAction Stop } |
{ Restart-PveVm -Node 'pve-node1' -VmId 100 -Confirm:$false -ErrorAction Stop } |
Should -Throw '*No active Proxmox VE session*'
}