mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-08-07 21:13:12 +00:00
df4cae01bc
Phase 1 — Missing Update/Set operations (10 cmdlets): - SDN: Set-PveSdnZone/Vnet/Subnet/Controller/Ipam/Dns + Invoke-PveSdnApply - Set-PveRole, Set-PveStorage, Set-PveApiToken Phase 2 — Cluster operations (8 cmdlets): - Get-PveClusterResource (cluster-wide inventory) - Get-PveTaskList, Stop-PveTask - Get/New/Set/Remove-PvePool - Get-PveBackupInfo (unprotected VMs) Phase 3 — VM & container gaps (14 cmdlets): - Move-PveVmDisk, Remove-PveVmDisk - Guest agent: Get-PveVmGuestOsInfo/FsInfo, Read/Write-PveVmGuestFile, Set-PveVmGuestPassword, Invoke-PveVmGuestFsTrim - Suspend/Resume-PveContainer, Resize-PveContainerDisk, New-PveContainerTemplate, Move-PveContainerVolume, Get-PveContainerInterface Phase 4 — Storage content management (4 cmdlets): - Get-PveStorageStatus, Remove/Set-PveStorageContent, New-PveStorageDisk Phase 5 — Node operations (6 cmdlets): - Get/Set-PveNodeConfig, Get/Set-PveNodeDns, Start/Stop-PveNodeVms Phase 6 — Access management (9 cmdlets): - Get/New/Set/Remove-PveGroup, Get/New/Set/Remove-PveDomain, Set-PvePassword Total: 169 cmdlets (was 118). Includes models, services, format views, Pester unit tests, manifest updates, README, CHANGELOG, API coverage docs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
183 lines
6.1 KiB
PowerShell
183 lines
6.1 KiB
PowerShell
#Requires -Module Pester
|
|
<#
|
|
.SYNOPSIS
|
|
Pester 5 tests for pool cmdlets:
|
|
Get-PvePool, New-PvePool, Set-PvePool, Remove-PvePool.
|
|
|
|
All tests are fully offline — no live Proxmox VE target is required.
|
|
If a cmdlet is not yet compiled the test is marked Skipped.
|
|
#>
|
|
|
|
BeforeAll {
|
|
. $PSScriptRoot/../_TestHelper.ps1
|
|
|
|
$script:Availability = @{}
|
|
foreach ($name in @('Get-PvePool', 'New-PvePool', 'Set-PvePool', 'Remove-PvePool')) {
|
|
$script:Availability[$name] = $null -ne (Get-Command $name -ErrorAction SilentlyContinue)
|
|
}
|
|
|
|
function Skip-IfMissing([string]$Name) {
|
|
if (-not $script:Availability[$Name]) {
|
|
Set-ItResult -Skipped -Because "$Name is not yet implemented in this build"
|
|
}
|
|
}
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Get-PvePool
|
|
# ---------------------------------------------------------------------------
|
|
Describe 'Get-PvePool' -Tag 'Unit' {
|
|
|
|
BeforeAll { $script:Cmd = Get-Command 'Get-PvePool' -ErrorAction SilentlyContinue }
|
|
|
|
Context 'Command existence' {
|
|
It 'Should be available after module import' {
|
|
Skip-IfMissing 'Get-PvePool'
|
|
$script:Cmd | Should -Not -BeNullOrEmpty
|
|
}
|
|
It 'Should be a CmdletInfo (binary cmdlet)' {
|
|
Skip-IfMissing 'Get-PvePool'
|
|
$script:Cmd.CommandType | Should -Be 'Cmdlet'
|
|
}
|
|
}
|
|
|
|
Context 'Parameter metadata' {
|
|
It 'Should have optional PoolId parameter' {
|
|
Skip-IfMissing 'Get-PvePool'
|
|
$script:Cmd.Parameters.ContainsKey('PoolId') | Should -BeTrue
|
|
}
|
|
}
|
|
|
|
Context 'Without active session' {
|
|
It 'Should throw when no session is active' {
|
|
Skip-IfMissing 'Get-PvePool'
|
|
{ Get-PvePool -ErrorAction Stop } |
|
|
Should -Throw '*No active Proxmox VE session*'
|
|
}
|
|
}
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# New-PvePool
|
|
# ---------------------------------------------------------------------------
|
|
Describe 'New-PvePool' -Tag 'Unit' {
|
|
|
|
BeforeAll { $script:Cmd = Get-Command 'New-PvePool' -ErrorAction SilentlyContinue }
|
|
|
|
Context 'Command existence' {
|
|
It 'Should be available after module import' {
|
|
Skip-IfMissing 'New-PvePool'
|
|
$script:Cmd | Should -Not -BeNullOrEmpty
|
|
}
|
|
}
|
|
|
|
Context 'ShouldProcess support' {
|
|
It 'Should support WhatIf' {
|
|
Skip-IfMissing 'New-PvePool'
|
|
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
|
|
}
|
|
}
|
|
|
|
Context 'Required parameters' {
|
|
It 'PoolId should be Mandatory' {
|
|
Skip-IfMissing 'New-PvePool'
|
|
$isMandatory = $script:Cmd.Parameters['PoolId'].ParameterSets.Values |
|
|
Where-Object { $_.IsMandatory }
|
|
$isMandatory | Should -Not -BeNullOrEmpty
|
|
}
|
|
}
|
|
|
|
Context 'Without active session' {
|
|
It 'Should throw when no session is active' {
|
|
Skip-IfMissing 'New-PvePool'
|
|
{ New-PvePool -PoolId 'testpool' -ErrorAction Stop } |
|
|
Should -Throw '*No active Proxmox VE session*'
|
|
}
|
|
}
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Set-PvePool
|
|
# ---------------------------------------------------------------------------
|
|
Describe 'Set-PvePool' -Tag 'Unit' {
|
|
|
|
BeforeAll { $script:Cmd = Get-Command 'Set-PvePool' -ErrorAction SilentlyContinue }
|
|
|
|
Context 'Command existence' {
|
|
It 'Should be available after module import' {
|
|
Skip-IfMissing 'Set-PvePool'
|
|
$script:Cmd | Should -Not -BeNullOrEmpty
|
|
}
|
|
}
|
|
|
|
Context 'ShouldProcess support' {
|
|
It 'Should support WhatIf' {
|
|
Skip-IfMissing 'Set-PvePool'
|
|
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
|
|
}
|
|
}
|
|
|
|
Context 'Required parameters' {
|
|
It 'PoolId should be Mandatory' {
|
|
Skip-IfMissing 'Set-PvePool'
|
|
$isMandatory = $script:Cmd.Parameters['PoolId'].ParameterSets.Values |
|
|
Where-Object { $_.IsMandatory }
|
|
$isMandatory | Should -Not -BeNullOrEmpty
|
|
}
|
|
}
|
|
|
|
Context 'Without active session' {
|
|
It 'Should throw when no session is active' {
|
|
Skip-IfMissing 'Set-PvePool'
|
|
{ Set-PvePool -PoolId 'testpool' -ErrorAction Stop } |
|
|
Should -Throw '*No active Proxmox VE session*'
|
|
}
|
|
}
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Remove-PvePool
|
|
# ---------------------------------------------------------------------------
|
|
Describe 'Remove-PvePool' -Tag 'Unit' {
|
|
|
|
BeforeAll { $script:Cmd = Get-Command 'Remove-PvePool' -ErrorAction SilentlyContinue }
|
|
|
|
Context 'Command existence' {
|
|
It 'Should be available after module import' {
|
|
Skip-IfMissing 'Remove-PvePool'
|
|
$script:Cmd | Should -Not -BeNullOrEmpty
|
|
}
|
|
}
|
|
|
|
Context 'ShouldProcess / ConfirmImpact' {
|
|
It 'Should support WhatIf' {
|
|
Skip-IfMissing 'Remove-PvePool'
|
|
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
|
|
}
|
|
It 'Should declare ConfirmImpact High' {
|
|
Skip-IfMissing 'Remove-PvePool'
|
|
$attr = $script:Cmd.ImplementingType.GetCustomAttributes(
|
|
[System.Management.Automation.CmdletAttribute], $false) |
|
|
Select-Object -First 1
|
|
$attr.ConfirmImpact | Should -Be ([System.Management.Automation.ConfirmImpact]::High)
|
|
}
|
|
}
|
|
|
|
Context 'Required parameters' {
|
|
It 'PoolId should be Mandatory' {
|
|
Skip-IfMissing 'Remove-PvePool'
|
|
$isMandatory = $script:Cmd.Parameters['PoolId'].ParameterSets.Values |
|
|
Where-Object { $_.IsMandatory }
|
|
$isMandatory | Should -Not -BeNullOrEmpty
|
|
}
|
|
}
|
|
|
|
Context 'Without active session' {
|
|
It 'Should throw when no session is active' {
|
|
Skip-IfMissing 'Remove-PvePool'
|
|
{ Remove-PvePool -PoolId 'testpool' -Confirm:$false -ErrorAction Stop } |
|
|
Should -Throw '*No active Proxmox VE session*'
|
|
}
|
|
}
|
|
}
|