From ae55dbf0d7fb7b9218b10d2b56c3155028d2cb2c Mon Sep 17 00:00:00 2001 From: Clint Branham Date: Fri, 20 Mar 2026 12:40:54 -0500 Subject: [PATCH] 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) --- .../Containers/ContainerLifecycle.Tests.ps1 | 2 +- .../ContainerSnapshotCmdlets.Tests.ps1 | 4 ++-- .../Integration/Integration.Tests.ps1 | 20 +++++++++---------- .../Network/SdnSubnetCmdlets.Tests.ps1 | 2 +- .../Snapshots/SnapshotCmdlets.Tests.ps1 | 4 ++-- .../Templates/TemplateCmdlets.Tests.ps1 | 2 +- .../Vms/VmLifecycle.Tests.ps1 | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/PSProxmoxVE.Tests/Containers/ContainerLifecycle.Tests.ps1 b/tests/PSProxmoxVE.Tests/Containers/ContainerLifecycle.Tests.ps1 index 8bb325c..582baba 100644 --- a/tests/PSProxmoxVE.Tests/Containers/ContainerLifecycle.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Containers/ContainerLifecycle.Tests.ps1 @@ -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*' } } diff --git a/tests/PSProxmoxVE.Tests/Containers/ContainerSnapshotCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Containers/ContainerSnapshotCmdlets.Tests.ps1 index 34050a9..c3e747b 100644 --- a/tests/PSProxmoxVE.Tests/Containers/ContainerSnapshotCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Containers/ContainerSnapshotCmdlets.Tests.ps1 @@ -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*' } } diff --git a/tests/PSProxmoxVE.Tests/Integration/Integration.Tests.ps1 b/tests/PSProxmoxVE.Tests/Integration/Integration.Tests.ps1 index 5df6e7f..eff8847 100644 --- a/tests/PSProxmoxVE.Tests/Integration/Integration.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Integration/Integration.Tests.ps1 @@ -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 ` diff --git a/tests/PSProxmoxVE.Tests/Network/SdnSubnetCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Network/SdnSubnetCmdlets.Tests.ps1 index 2d19df6..e2ee4b7 100644 --- a/tests/PSProxmoxVE.Tests/Network/SdnSubnetCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Network/SdnSubnetCmdlets.Tests.ps1 @@ -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*' } } diff --git a/tests/PSProxmoxVE.Tests/Snapshots/SnapshotCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Snapshots/SnapshotCmdlets.Tests.ps1 index 2d6c797..c83b8f7 100644 --- a/tests/PSProxmoxVE.Tests/Snapshots/SnapshotCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Snapshots/SnapshotCmdlets.Tests.ps1 @@ -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*' } } diff --git a/tests/PSProxmoxVE.Tests/Templates/TemplateCmdlets.Tests.ps1 b/tests/PSProxmoxVE.Tests/Templates/TemplateCmdlets.Tests.ps1 index dff1391..37b231e 100644 --- a/tests/PSProxmoxVE.Tests/Templates/TemplateCmdlets.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Templates/TemplateCmdlets.Tests.ps1 @@ -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*' } } diff --git a/tests/PSProxmoxVE.Tests/Vms/VmLifecycle.Tests.ps1 b/tests/PSProxmoxVE.Tests/Vms/VmLifecycle.Tests.ps1 index 007d2da..929b27e 100644 --- a/tests/PSProxmoxVE.Tests/Vms/VmLifecycle.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/Vms/VmLifecycle.Tests.ps1 @@ -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*' }