mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-08-31 17:28:06 +00:00
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>
This commit is contained in:
@@ -10,21 +10,7 @@
|
||||
#>
|
||||
|
||||
BeforeAll {
|
||||
$moduleRoot = Resolve-Path (Join-Path $PSScriptRoot '../../../src/PSProxmoxVE')
|
||||
$dllCandidates = @(
|
||||
Join-Path $moduleRoot 'bin/Debug/net9.0/PSProxmoxVE.dll'
|
||||
Join-Path $moduleRoot 'bin/Release/net9.0/PSProxmoxVE.dll'
|
||||
Join-Path $moduleRoot 'bin/Debug/net48/PSProxmoxVE.dll'
|
||||
Join-Path $moduleRoot 'bin/Release/net48/PSProxmoxVE.dll'
|
||||
)
|
||||
|
||||
$script:ModuleDll = $dllCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1
|
||||
|
||||
if ($null -eq $script:ModuleDll) {
|
||||
throw "PSProxmoxVE.dll not found. Build the project before running Pester tests."
|
||||
}
|
||||
|
||||
Import-Module $script:ModuleDll -Force -ErrorAction Stop
|
||||
. $PSScriptRoot/../_TestHelper.ps1
|
||||
|
||||
# Pre-calculate availability for each cmdlet.
|
||||
$script:Availability = @{}
|
||||
|
||||
@@ -10,21 +10,7 @@
|
||||
#>
|
||||
|
||||
BeforeAll {
|
||||
$moduleRoot = Resolve-Path (Join-Path $PSScriptRoot '../../../src/PSProxmoxVE')
|
||||
$dllCandidates = @(
|
||||
Join-Path $moduleRoot 'bin/Debug/net9.0/PSProxmoxVE.dll'
|
||||
Join-Path $moduleRoot 'bin/Release/net9.0/PSProxmoxVE.dll'
|
||||
Join-Path $moduleRoot 'bin/Debug/net48/PSProxmoxVE.dll'
|
||||
Join-Path $moduleRoot 'bin/Release/net48/PSProxmoxVE.dll'
|
||||
)
|
||||
|
||||
$script:ModuleDll = $dllCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1
|
||||
|
||||
if ($null -eq $script:ModuleDll) {
|
||||
throw "PSProxmoxVE.dll not found. Build the project before running Pester tests."
|
||||
}
|
||||
|
||||
Import-Module $script:ModuleDll -Force -ErrorAction Stop
|
||||
. $PSScriptRoot/../_TestHelper.ps1
|
||||
|
||||
$script:CmdExists = $null -ne (Get-Command 'Get-PveContainer' -ErrorAction SilentlyContinue)
|
||||
}
|
||||
@@ -34,7 +20,7 @@ Describe 'Get-PveContainer' {
|
||||
Context 'Command existence' {
|
||||
It 'Get-PveContainer should be listed in the module manifest CmdletsToExport' {
|
||||
# The .psd1 declares the cmdlet; implementation may be pending.
|
||||
$manifestPath = Join-Path $moduleRoot 'PSProxmoxVE.psd1'
|
||||
$manifestPath = Join-Path (Get-Module PSProxmoxVE).ModuleBase 'PSProxmoxVE.psd1'
|
||||
if (Test-Path $manifestPath) {
|
||||
$manifest = Import-PowerShellDataFile $manifestPath
|
||||
$manifest.CmdletsToExport | Should -Contain 'Get-PveContainer'
|
||||
|
||||
Reference in New Issue
Block a user