Files
PSProxmoxVE/tests/PSProxmoxVE.Tests/Connection/Test-PveConnection.Tests.ps1
T
Clint Branham 0dc7f5f833 fix(test): fix assembly loading, remove mock server, resolve test warnings
- 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>
2026-03-18 18:11:33 -05:00

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]
}
}
}