mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-08-24 03:26:29 +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.4 KiB
PowerShell
44 lines
1.4 KiB
PowerShell
#Requires -Module Pester
|
|
|
|
BeforeAll {
|
|
. $PSScriptRoot/_IntegrationHelper.ps1
|
|
Connect-TestPve
|
|
|
|
# Find a test VM for cloud-init config read test
|
|
$script:TestVmId = Find-TestVm
|
|
$script:LinuxVmId = Find-TestVm -Name 'pester-linux-vm'
|
|
}
|
|
|
|
AfterAll {
|
|
# Read-only tests — no cleanup needed
|
|
Disconnect-TestPve
|
|
}
|
|
|
|
Describe 'Cloud-Init — Integration' -Tag 'Integration' {
|
|
Context 'Cloud-Init' {
|
|
It 'Should get cloud-init config' {
|
|
if (Skip-IfNoTarget) { return }
|
|
if ($null -eq $script:TestVmId) {
|
|
Set-ItResult -Skipped -Because 'No test VM found'
|
|
return
|
|
}
|
|
|
|
# Get-PveCloudInitConfig should not throw even if the VM has no cloud-init drive.
|
|
{ Get-PveCloudInitConfig -Node $script:Node -VmId $script:TestVmId -ErrorAction Stop } |
|
|
Should -Not -Throw
|
|
}
|
|
|
|
It 'Should regenerate cloud-init image (Invoke-PveCloudInitRegenerate)' {
|
|
if (Skip-IfNoTarget) { return }
|
|
if ($null -eq $script:LinuxVmId) {
|
|
Set-ItResult -Skipped -Because 'Linux VM was not provisioned (PVETEST_PASSWORD may not be set)'
|
|
return
|
|
}
|
|
|
|
# The Linux VM has a cloud-init drive from provisioning
|
|
{ Invoke-PveCloudInitRegenerate -Node $script:Node -VmId $script:LinuxVmId -Wait -ErrorAction Stop } |
|
|
Should -Not -Throw
|
|
}
|
|
}
|
|
}
|