mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-07-26 07:58:14 +00:00
fix(test): add -Confirm:$false to all ConfirmImpact.High cmdlet calls in tests
ConfirmImpact.High causes interactive confirmation prompts in non-interactive CI, blocking before ProcessRecord runs. Add -Confirm:$false to all Stop-PveVm, Reset-PveVm, Remove-*, Restore-*, and New-PveTemplate calls in both unit and integration tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -244,7 +244,7 @@ Describe 'Stop-PveContainer' {
|
||||
Context 'Without active session' {
|
||||
It 'Should throw when no session is active' {
|
||||
Skip-IfMissing 'Stop-PveContainer'
|
||||
{ Stop-PveContainer -Node 'pve-node1' -VmId 200 -ErrorAction Stop } |
|
||||
{ Stop-PveContainer -Node 'pve-node1' -VmId 200 -Confirm:$false -ErrorAction Stop } |
|
||||
Should -Throw '*No active Proxmox VE session*'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ Describe 'Remove-PveContainerSnapshot' {
|
||||
Context 'Without active session' {
|
||||
It 'Should throw when no session is active (without -WhatIf)' {
|
||||
Skip-IfMissing 'Remove-PveContainerSnapshot'
|
||||
{ Remove-PveContainerSnapshot -Node 'pve-node1' -VmId 100 -Name 'snap1' -ErrorAction Stop } |
|
||||
{ Remove-PveContainerSnapshot -Node 'pve-node1' -VmId 100 -Name 'snap1' -Confirm:$false -ErrorAction Stop } |
|
||||
Should -Throw '*No active Proxmox VE session*'
|
||||
}
|
||||
}
|
||||
@@ -292,7 +292,7 @@ Describe 'Restore-PveContainerSnapshot' {
|
||||
Context 'Without active session' {
|
||||
It 'Should throw when no session is active (without -WhatIf)' {
|
||||
Skip-IfMissing 'Restore-PveContainerSnapshot'
|
||||
{ Restore-PveContainerSnapshot -Node 'pve-node1' -VmId 100 -Name 'snap1' -ErrorAction Stop } |
|
||||
{ Restore-PveContainerSnapshot -Node 'pve-node1' -VmId 100 -Name 'snap1' -Confirm:$false -ErrorAction Stop } |
|
||||
Should -Throw '*No active Proxmox VE session*'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ AfterAll {
|
||||
|
||||
foreach ($vmId in $script:CreatedVmIds) {
|
||||
try {
|
||||
Stop-PveVm -Node $script:Node -VmId $vmId -ErrorAction SilentlyContinue | Out-Null
|
||||
Stop-PveVm -Node $script:Node -VmId $vmId -Confirm:$false -ErrorAction SilentlyContinue | Out-Null
|
||||
Start-Sleep -Seconds 3
|
||||
Remove-PveVm -Node $script:Node -VmId $vmId -Force -Purge -Confirm:$false -ErrorAction SilentlyContinue
|
||||
}
|
||||
@@ -381,7 +381,7 @@ Describe 'Integration Tests' -Tag 'Integration' {
|
||||
$startTask = Start-PveVm -Node $script:Node -VmId $script:TestVmId -Wait
|
||||
$startTask | Should -Not -BeNullOrEmpty
|
||||
|
||||
$stopTask = Stop-PveVm -Node $script:Node -VmId $script:TestVmId -Wait
|
||||
$stopTask = Stop-PveVm -Node $script:Node -VmId $script:TestVmId -Wait -Confirm:$false
|
||||
$stopTask | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
@@ -392,10 +392,10 @@ Describe 'Integration Tests' -Tag 'Integration' {
|
||||
Start-PveVm -Node $script:Node -VmId $script:TestVmId -Wait | Out-Null
|
||||
|
||||
# Hard reset (no ACPI — works even without guest OS)
|
||||
$task = Reset-PveVm -Node $script:Node -VmId $script:TestVmId -Wait
|
||||
$task = Reset-PveVm -Node $script:Node -VmId $script:TestVmId -Wait -Confirm:$false
|
||||
$task | Should -Not -BeNullOrEmpty
|
||||
|
||||
Stop-PveVm -Node $script:Node -VmId $script:TestVmId -Wait | Out-Null
|
||||
Stop-PveVm -Node $script:Node -VmId $script:TestVmId -Wait -Confirm:$false | Out-Null
|
||||
}
|
||||
|
||||
It 'Should clone a VM' {
|
||||
@@ -430,7 +430,7 @@ Describe 'Integration Tests' -Tag 'Integration' {
|
||||
# Ensure the VM is stopped for snapshot
|
||||
$vm = Get-PveVm -Node $script:Node | Where-Object { $_.VmId -eq $script:TestVmId }
|
||||
if ($vm.Status -eq 'running') {
|
||||
Stop-PveVm -Node $script:Node -VmId $script:TestVmId -Wait | Out-Null
|
||||
Stop-PveVm -Node $script:Node -VmId $script:TestVmId -Wait -Confirm:$false | Out-Null
|
||||
}
|
||||
|
||||
$snapName = 'pester-snap'
|
||||
@@ -525,7 +525,7 @@ Describe 'Integration Tests' -Tag 'Integration' {
|
||||
$task.IsSuccessful | Should -BeTrue
|
||||
|
||||
# Clean up
|
||||
Stop-PveVm -Node $script:Node -VmId $script:TestVmId -Wait | Out-Null
|
||||
Stop-PveVm -Node $script:Node -VmId $script:TestVmId -Wait -Confirm:$false | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,7 +667,7 @@ Describe 'Integration Tests' -Tag 'Integration' {
|
||||
It 'Should gracefully restart a VM via ACPI (Restart-PveVm)' {
|
||||
if (Skip-IfNoLinuxVm) { return }
|
||||
|
||||
$task = Restart-PveVm -Node $script:Node -VmId $script:LinuxVmId -Wait
|
||||
$task = Restart-PveVm -Node $script:Node -VmId $script:LinuxVmId -Wait -Confirm:$false
|
||||
$task | Should -Not -BeNullOrEmpty
|
||||
|
||||
# Wait a moment for the VM to come back up
|
||||
@@ -680,7 +680,7 @@ Describe 'Integration Tests' -Tag 'Integration' {
|
||||
It 'Should gracefully stop a VM via ACPI (Stop-PveVm)' {
|
||||
if (Skip-IfNoLinuxVm) { return }
|
||||
|
||||
$task = Stop-PveVm -Node $script:Node -VmId $script:LinuxVmId -Wait
|
||||
$task = Stop-PveVm -Node $script:Node -VmId $script:LinuxVmId -Wait -Confirm:$false
|
||||
$task | Should -Not -BeNullOrEmpty
|
||||
|
||||
$vm = Get-PveVm -Node $script:Node |
|
||||
@@ -698,7 +698,7 @@ Describe 'Integration Tests' -Tag 'Integration' {
|
||||
$vm = Get-PveVm -Node $script:Node |
|
||||
Where-Object { $_.VmId -eq $script:LinuxVmId }
|
||||
if ($vm.Status -eq 'running') {
|
||||
Stop-PveVm -Node $script:Node -VmId $script:LinuxVmId -Wait | Out-Null
|
||||
Stop-PveVm -Node $script:Node -VmId $script:LinuxVmId -Wait -Confirm:$false | Out-Null
|
||||
}
|
||||
|
||||
{ New-PveTemplate -Node $script:Node -VmId $script:LinuxVmId -Confirm:$false -ErrorAction Stop } |
|
||||
@@ -745,7 +745,7 @@ Describe 'Integration Tests' -Tag 'Integration' {
|
||||
# Ensure stopped
|
||||
$vm = Get-PveVm -Node $script:Node | Where-Object { $_.VmId -eq $script:TestVmId }
|
||||
if ($vm.Status -eq 'running') {
|
||||
Stop-PveVm -Node $script:Node -VmId $script:TestVmId -Wait | Out-Null
|
||||
Stop-PveVm -Node $script:Node -VmId $script:TestVmId -Wait -Confirm:$false | Out-Null
|
||||
}
|
||||
|
||||
{ Remove-PveVm `
|
||||
|
||||
@@ -212,7 +212,7 @@ Describe 'Remove-PveSdnSubnet' {
|
||||
Context 'Without active session' {
|
||||
It 'Should throw when no session is active (without -WhatIf)' {
|
||||
Skip-IfMissing 'Remove-PveSdnSubnet'
|
||||
{ Remove-PveSdnSubnet -Vnet 'myvnet' -Subnet '10.0.0.0/24' -ErrorAction Stop } |
|
||||
{ Remove-PveSdnSubnet -Vnet 'myvnet' -Subnet '10.0.0.0/24' -Confirm:$false -ErrorAction Stop } |
|
||||
Should -Throw '*No active Proxmox VE session*'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ Describe 'Remove-PveSnapshot' {
|
||||
Context 'Without active session' {
|
||||
It 'Should throw when no session is active (without -WhatIf)' {
|
||||
Skip-IfMissing 'Remove-PveSnapshot'
|
||||
{ Remove-PveSnapshot -Node 'pve-node1' -VmId 100 -Name 'snap1' -ErrorAction Stop } |
|
||||
{ Remove-PveSnapshot -Node 'pve-node1' -VmId 100 -Name 'snap1' -Confirm:$false -ErrorAction Stop } |
|
||||
Should -Throw '*No active Proxmox VE session*'
|
||||
}
|
||||
}
|
||||
@@ -294,7 +294,7 @@ Describe 'Restore-PveSnapshot' {
|
||||
Context 'Without active session' {
|
||||
It 'Should throw when no session is active (without -WhatIf)' {
|
||||
Skip-IfMissing 'Restore-PveSnapshot'
|
||||
{ Restore-PveSnapshot -Node 'pve-node1' -VmId 100 -Name 'snap1' -ErrorAction Stop } |
|
||||
{ Restore-PveSnapshot -Node 'pve-node1' -VmId 100 -Name 'snap1' -Confirm:$false -ErrorAction Stop } |
|
||||
Should -Throw '*No active Proxmox VE session*'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ Describe 'New-PveTemplate' {
|
||||
Context 'Without active session' {
|
||||
It 'Should throw when no session is active (without -WhatIf)' {
|
||||
Skip-IfMissing 'New-PveTemplate'
|
||||
{ New-PveTemplate -Node 'pve-node1' -VmId 9000 -ErrorAction Stop } |
|
||||
{ New-PveTemplate -Node 'pve-node1' -VmId 9000 -Confirm:$false -ErrorAction Stop } |
|
||||
Should -Throw '*No active Proxmox VE session*'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ Describe 'Stop-PveVm' {
|
||||
|
||||
Context 'Without active session' {
|
||||
It 'Should throw when no session is active (without -WhatIf)' {
|
||||
{ Stop-PveVm -Node 'pve-node1' -VmId 100 -ErrorAction Stop } |
|
||||
{ Stop-PveVm -Node 'pve-node1' -VmId 100 -Confirm:$false -ErrorAction Stop } |
|
||||
Should -Throw '*No active Proxmox VE session*'
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user