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>
57 lines
2.0 KiB
PowerShell
57 lines
2.0 KiB
PowerShell
#Requires -Module Pester
|
|
<#
|
|
.SYNOPSIS
|
|
Pester 5 tests for Disconnect-PveServer.
|
|
All tests are fully offline — no live Proxmox VE target is required.
|
|
#>
|
|
|
|
BeforeAll {
|
|
. $PSScriptRoot/../_TestHelper.ps1
|
|
}
|
|
|
|
Describe 'Disconnect-PveServer' {
|
|
|
|
Context 'Command existence' {
|
|
It 'Should be available after module import' {
|
|
Get-Command 'Disconnect-PveServer' -ErrorAction SilentlyContinue |
|
|
Should -Not -BeNullOrEmpty
|
|
}
|
|
|
|
It 'Should be a CmdletInfo (binary cmdlet)' {
|
|
(Get-Command 'Disconnect-PveServer').CommandType | Should -Be 'Cmdlet'
|
|
}
|
|
}
|
|
|
|
Context 'Parameter metadata' {
|
|
BeforeAll {
|
|
$script:Cmd = Get-Command 'Disconnect-PveServer'
|
|
}
|
|
|
|
It 'Should support ShouldProcess (have WhatIf and Confirm parameters)' {
|
|
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
|
|
$script:Cmd.Parameters.ContainsKey('Confirm') | Should -BeTrue
|
|
}
|
|
|
|
It 'Should declare ConfirmImpact Low (no explicit -Confirm needed for normal use)' {
|
|
# SupportsShouldProcess is reflected as WhatIf/Confirm parameters.
|
|
# ConfirmImpact=Low means PowerShell will not auto-prompt; just verify the
|
|
# attribute is present by confirming ShouldProcess support is enabled.
|
|
$script:Cmd.Parameters.ContainsKey('WhatIf') | Should -BeTrue
|
|
}
|
|
}
|
|
|
|
Context 'Behaviour when no session is active' {
|
|
It 'Should run without error and emit a warning when no session exists' {
|
|
# Ensure module state has no active session by disconnecting first (may already be null).
|
|
# Disconnect-PveServer should emit a warning, not throw.
|
|
{ Disconnect-PveServer -ErrorAction Stop } | Should -Not -Throw
|
|
}
|
|
}
|
|
|
|
Context 'WhatIf support' {
|
|
It 'Should accept -WhatIf without throwing' {
|
|
{ Disconnect-PveServer -WhatIf -ErrorAction Stop } | Should -Not -Throw
|
|
}
|
|
}
|
|
}
|