mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-08-29 00:17:04 +00:00
12874d168d
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>
44 lines
1.3 KiB
PowerShell
44 lines
1.3 KiB
PowerShell
#Requires -Module Pester
|
|
|
|
BeforeAll {
|
|
. $PSScriptRoot/_IntegrationHelper.ps1
|
|
Connect-TestPve
|
|
|
|
# Find an existing test VM to use for task tests
|
|
$script:TestVmId = Find-TestVm
|
|
}
|
|
|
|
AfterAll {
|
|
# Read-only tests — no cleanup needed
|
|
Disconnect-TestPve
|
|
}
|
|
|
|
Describe 'Tasks — Integration' -Tag 'Integration' {
|
|
|
|
Context 'Tasks' {
|
|
It 'Should get a task by UPID and wait for completion' {
|
|
if (Skip-IfNoTarget) { return }
|
|
if ($null -eq $script:TestVmId) {
|
|
Set-ItResult -Skipped -Because 'No test VM was created'
|
|
return
|
|
}
|
|
|
|
# Start the VM to get a task object
|
|
$startResult = Start-PveVm -Node $script:Node -VmId $script:TestVmId
|
|
$startResult | Should -Not -BeNullOrEmpty
|
|
$startResult.Upid | Should -Not -BeNullOrEmpty
|
|
|
|
# Wait for the task to complete
|
|
{ Wait-PveTask -Node $script:Node -Upid $startResult.Upid } | Should -Not -Throw
|
|
|
|
# Get the task status
|
|
$task = Get-PveTask -Node $script:Node -Upid $startResult.Upid
|
|
$task | Should -Not -BeNullOrEmpty
|
|
$task.IsSuccessful | Should -BeTrue
|
|
|
|
# Clean up
|
|
Stop-PveVm -Node $script:Node -VmId $script:TestVmId -Wait -Timeout 30 -Confirm:$false | Out-Null
|
|
}
|
|
}
|
|
}
|