mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-07-26 07:58:14 +00:00
0dc7f5f833
- Create shared _TestHelper.ps1 for reliable module loading in both local dev and CI (fixes System.Runtime 9.0.0.0 FileNotFoundException on PS 7.x by trying Import-Module by name first, then local paths) - Use (Get-Module).ModuleBase for manifest path resolution - Remove PSProxmoxVE.MockServer project and MockIntegration tests - Remove MockIntegration from ExcludeTag filters Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
70 lines
2.2 KiB
PowerShell
70 lines
2.2 KiB
PowerShell
#Requires -Module Pester
|
|
<#
|
|
.SYNOPSIS
|
|
Pester 5 tests for Test-PveConnection.
|
|
All tests are fully offline — no live Proxmox VE target is required.
|
|
#>
|
|
|
|
BeforeAll {
|
|
. $PSScriptRoot/../_TestHelper.ps1
|
|
}
|
|
|
|
Describe 'Test-PveConnection' {
|
|
|
|
Context 'Command existence' {
|
|
It 'Should be available after module import' {
|
|
Get-Command 'Test-PveConnection' -ErrorAction SilentlyContinue |
|
|
Should -Not -BeNullOrEmpty
|
|
}
|
|
|
|
It 'Should be a CmdletInfo (binary cmdlet)' {
|
|
(Get-Command 'Test-PveConnection').CommandType | Should -Be 'Cmdlet'
|
|
}
|
|
}
|
|
|
|
Context 'Parameter metadata' {
|
|
BeforeAll {
|
|
$script:Cmd = Get-Command 'Test-PveConnection'
|
|
}
|
|
|
|
It 'Should have a Detailed switch parameter' {
|
|
$script:Cmd.Parameters.ContainsKey('Detailed') | Should -BeTrue
|
|
$script:Cmd.Parameters['Detailed'].ParameterType |
|
|
Should -Be ([System.Management.Automation.SwitchParameter])
|
|
}
|
|
|
|
It 'Detailed should not be Mandatory' {
|
|
$detailed = $script:Cmd.Parameters['Detailed']
|
|
$isMandatory = $detailed.ParameterSets.Values | Where-Object { $_.IsMandatory }
|
|
$isMandatory | Should -BeNullOrEmpty
|
|
}
|
|
}
|
|
|
|
Context 'Behaviour without an active session' {
|
|
It 'Should return $false when no session is active (default mode)' {
|
|
$result = Test-PveConnection
|
|
$result | Should -BeFalse
|
|
}
|
|
|
|
It 'Should return nothing when -Detailed is specified and no session is active' {
|
|
$result = Test-PveConnection -Detailed
|
|
$result | Should -BeNullOrEmpty
|
|
}
|
|
|
|
It 'Should not throw when called with no arguments and no session' {
|
|
{ Test-PveConnection -ErrorAction Stop } | Should -Not -Throw
|
|
}
|
|
|
|
It 'Should not throw when called with -Detailed and no session' {
|
|
{ Test-PveConnection -Detailed -ErrorAction Stop } | Should -Not -Throw
|
|
}
|
|
}
|
|
|
|
Context 'Output type contract' {
|
|
It 'Default output is a boolean' {
|
|
$result = Test-PveConnection
|
|
$result | Should -BeOfType [bool]
|
|
}
|
|
}
|
|
}
|