mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-08-13 07:36:52 +00:00
94bc1a9d73
- Fix bare Skip-IfNoTarget calls in 13_Firewall and 14_Backup (missing if/return pattern caused tests to run when they should skip) - Validate modifier-only switches in dev.ps1 (-Force/-Reprovision without an action switch now errors instead of defaulting to -Shell) - Add force-cleanup to usage text in run-integration.sh - Add --connect-timeout/--max-time to guest agent curl in wait-for-pve.sh Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
64 lines
2.2 KiB
PowerShell
64 lines
2.2 KiB
PowerShell
#Requires -Module Pester
|
|
|
|
BeforeAll {
|
|
. $PSScriptRoot/_IntegrationHelper.ps1
|
|
Connect-TestPve
|
|
|
|
$script:BackupTestJobId = $null
|
|
}
|
|
|
|
AfterAll {
|
|
if ($null -eq $script:SkipReason) {
|
|
try {
|
|
if ($script:BackupTestJobId) {
|
|
Remove-PveBackupJob -Id $script:BackupTestJobId -Confirm:$false -ErrorAction SilentlyContinue
|
|
}
|
|
} catch { }
|
|
}
|
|
Disconnect-TestPve
|
|
}
|
|
|
|
Describe 'Backup Jobs — Integration' -Tag 'Integration' {
|
|
|
|
Context 'Backup Jobs' {
|
|
It 'Should create a backup job' {
|
|
if (Skip-IfNoTarget) { return }
|
|
{ New-PveBackupJob -Schedule 'sat 03:00' -Storage $script:Storage -Mode snapshot -All -Comment 'pester-test-backup' -ErrorAction Stop } | Should -Not -Throw
|
|
}
|
|
|
|
It 'Should list backup jobs and find the test job' {
|
|
if (Skip-IfNoTarget) { return }
|
|
$jobs = Get-PveBackupJob
|
|
$testJob = $jobs | Where-Object { $_.Comment -eq 'pester-test-backup' }
|
|
$testJob | Should -Not -BeNullOrEmpty
|
|
$script:BackupTestJobId = $testJob.Id
|
|
}
|
|
|
|
It 'Should update the backup job' {
|
|
if (Skip-IfNoTarget) { return }
|
|
if (-not $script:BackupTestJobId) {
|
|
Set-ItResult -Skipped -Because 'No test backup job was created'
|
|
}
|
|
{ Set-PveBackupJob -Id $script:BackupTestJobId -Comment 'pester-test-updated' -ErrorAction Stop } | Should -Not -Throw
|
|
}
|
|
|
|
It 'Should remove the backup job' {
|
|
if (Skip-IfNoTarget) { return }
|
|
if (-not $script:BackupTestJobId) {
|
|
Set-ItResult -Skipped -Because 'No test backup job was created'
|
|
}
|
|
{ Remove-PveBackupJob -Id $script:BackupTestJobId -Confirm:$false -ErrorAction Stop } | Should -Not -Throw
|
|
}
|
|
|
|
It 'Should verify the backup job was removed' {
|
|
if (Skip-IfNoTarget) { return }
|
|
if (-not $script:BackupTestJobId) {
|
|
Set-ItResult -Skipped -Because 'No test backup job was created'
|
|
}
|
|
$jobs = Get-PveBackupJob
|
|
$testJob = $jobs | Where-Object { $_.Id -eq $script:BackupTestJobId }
|
|
$testJob | Should -BeNullOrEmpty
|
|
}
|
|
}
|
|
}
|