mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-08-27 07:27:28 +00:00
refactor: split monolithic integration tests into numbered per-area files
Split the 1544-line Integration.Tests.ps1 into 18 focused test files with numeric prefixes for execution ordering. New shared helper (_IntegrationHelper.ps1): - Credential-based auth (root@pam) instead of API tokens - Skip helpers for env var checks - Resource discovery (Find-TestVm) for cross-file dependencies - Register-TestResource for env-var state passing between files Files created: 00_Connection, 01_Nodes, 02_Users, 03_Storage, 03a_SharedStorage, 04_Network, 05_SDN, 06_VMs, 07_Snapshots, 08_Templates, 09_CloudInit, 10_Containers, 11_LinuxVM, 12_OVA, 13_Firewall, 14_Backup, 15_Tasks, 99_Cleanup Key changes: - All tests use root@pam credentials (not API tokens) - Each file self-contained with own BeforeAll/AfterAll cleanup - Token CRUD tests now idempotent (remove-before-create) - 99_Cleanup is safety-net for any leftover pester-* resources - SharedStorage renamed to 03a_SharedStorage Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
#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' {
|
||||
Skip-IfNoTarget
|
||||
{ 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' {
|
||||
Skip-IfNoTarget
|
||||
$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' {
|
||||
Skip-IfNoTarget
|
||||
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' {
|
||||
Skip-IfNoTarget
|
||||
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' {
|
||||
Skip-IfNoTarget
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user