Files
PSProxmoxVE/tests/PSProxmoxVE.Tests/Integration/03_Storage.Tests.ps1
T
Clint Branham 12874d168d 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>
2026-03-25 11:51:49 -05:00

92 lines
2.9 KiB
PowerShell

#Requires -Module Pester
BeforeAll {
. $PSScriptRoot/_IntegrationHelper.ps1
Connect-TestPve
}
AfterAll {
if (-not $script:SkipReason) {
# Clean up pester-store if it still exists
try { Remove-PveStorage -Storage 'pester-store' -Confirm:$false -ErrorAction SilentlyContinue } catch { }
}
Disconnect-TestPve
}
Describe 'Storage — Integration' -Tag 'Integration' {
Context 'Storage' {
It 'Should list storage' {
if (Skip-IfNoTarget) { return }
$storage = Get-PveStorage -Node $script:Node
$storage | Should -Not -BeNullOrEmpty
}
It 'Should list storage content' {
if (Skip-IfNoTarget) { return }
{ Get-PveStorageContent `
-Node $script:Node `
-Storage $script:Storage `
-ErrorAction Stop } | Should -Not -Throw
}
It 'Should upload an ISO' {
if (Skip-IfNoStorage) { return }
if (-not (Test-Path $script:IsoPath)) {
Set-ItResult -Skipped -Because "ISO file not found at PVETEST_ISO_PATH: $($script:IsoPath)"
return
}
{
Send-PveFile `
-Node $script:Node `
-Storage $script:Storage `
-Path $script:IsoPath `
-ErrorAction Stop
} | Should -Not -Throw
}
}
Context 'Storage — CRUD' {
It 'Should create a directory storage (New-PveStorage)' {
if (Skip-IfNoTarget) { return }
$result = New-PveStorage -Storage 'pester-store' -Type 'dir' `
-Path '/tmp/pester-storage' -Content 'iso,vztmpl,backup' `
-ErrorAction Stop
$result | Should -Not -BeNullOrEmpty
}
It 'Should list and find the new storage (Get-PveStorage)' {
if (Skip-IfNoTarget) { return }
$storages = Get-PveStorage -Node $script:Node
$storages | Where-Object { $_.Storage -eq 'pester-store' } |
Should -Not -BeNullOrEmpty
}
It 'Should remove the storage (Remove-PveStorage)' {
if (Skip-IfNoTarget) { return }
{ Remove-PveStorage -Storage 'pester-store' -Confirm:$false -ErrorAction Stop } |
Should -Not -Throw
}
}
Context 'Storage — Download' {
It 'Should download a file from URL to storage (Invoke-PveStorageDownload)' {
if (Skip-IfNoTarget) { return }
$templateUrl = 'http://download.proxmox.com/images/system/alpine-3.20-default_20240908_amd64.tar.xz'
$task = Invoke-PveStorageDownload -Node $script:Node -Storage $script:Storage `
-Url $templateUrl -Filename 'alpine-3.20-default_20240908_amd64.tar.xz' `
-ContentType 'vztmpl' -Wait -ErrorAction Stop
$task | Should -Not -BeNullOrEmpty
}
}
}