mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-08-31 01:09:17 +00:00
fix(ci): fix xunit test, net48 build isolation, mock server check, Pester config
- Update BaseUrl test to expect trailing slash (matches code change) - Revert upload-artifact to v4 (v5 doesn't exist yet) - Build net48 job restores only src/test projects (excludes MockServer) - MockServer.Tests.ps1: fix net10.0 -> net9.0 DLL paths, fix build check - Unit tests: use New-PesterConfiguration instead of -CI flag (fixes AmbiguousParameterSet on PS 5.1), exclude MockIntegration tag Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,9 +16,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
dotnet-version: '9.0.x'
|
dotnet-version: '9.0.x'
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore
|
run: |
|
||||||
|
dotnet restore src/PSProxmoxVE/PSProxmoxVE.csproj
|
||||||
|
dotnet restore tests/PSProxmoxVE.Core.Tests/PSProxmoxVE.Core.Tests.csproj
|
||||||
- name: Build net48
|
- name: Build net48
|
||||||
run: dotnet build --configuration Release --framework net48 --no-restore
|
run: |
|
||||||
|
dotnet build src/PSProxmoxVE/PSProxmoxVE.csproj --configuration Release --framework net48 --no-restore
|
||||||
|
dotnet build tests/PSProxmoxVE.Core.Tests/PSProxmoxVE.Core.Tests.csproj --configuration Release --framework net48 --no-restore
|
||||||
- name: Test net48
|
- name: Test net48
|
||||||
run: dotnet test tests/PSProxmoxVE.Core.Tests/PSProxmoxVE.Core.Tests.csproj --configuration Release --framework net48 --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage
|
run: dotnet test tests/PSProxmoxVE.Core.Tests/PSProxmoxVE.Core.Tests.csproj --configuration Release --framework net48 --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage
|
||||||
- name: Upload coverage
|
- name: Upload coverage
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Upload test results
|
- name: Upload test results
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: integration-test-results
|
name: integration-test-results
|
||||||
path: TestResults/
|
path: TestResults/
|
||||||
|
|||||||
@@ -93,14 +93,30 @@ jobs:
|
|||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
Import-Module Pester -MinimumVersion 5.0
|
Import-Module Pester -MinimumVersion 5.0
|
||||||
Invoke-Pester tests/PSProxmoxVE.Tests -ExcludeTag Integration -CI -OutputFormat NUnitXml -OutputFile TestResults/pester-results.xml
|
$config = New-PesterConfiguration
|
||||||
|
$config.Run.Path = "tests/PSProxmoxVE.Tests"
|
||||||
|
$config.Run.Exit = $true
|
||||||
|
$config.Filter.ExcludeTag = @("Integration", "MockIntegration")
|
||||||
|
$config.Output.Verbosity = "Detailed"
|
||||||
|
$config.TestResult.Enabled = $true
|
||||||
|
$config.TestResult.OutputFormat = "NUnitXml"
|
||||||
|
$config.TestResult.OutputPath = "TestResults/pester-results.xml"
|
||||||
|
Invoke-Pester -Configuration $config
|
||||||
|
|
||||||
- name: Run Pester tests (PS 7.x)
|
- name: Run Pester tests (PS 7.x)
|
||||||
if: matrix.ps_version != '5.1'
|
if: matrix.ps_version != '5.1'
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
Import-Module Pester -MinimumVersion 5.0
|
Import-Module Pester -MinimumVersion 5.0
|
||||||
Invoke-Pester tests/PSProxmoxVE.Tests -ExcludeTag Integration -CI -OutputFormat NUnitXml -OutputFile TestResults/pester-results.xml
|
$config = New-PesterConfiguration
|
||||||
|
$config.Run.Path = "tests/PSProxmoxVE.Tests"
|
||||||
|
$config.Run.Exit = $true
|
||||||
|
$config.Filter.ExcludeTag = @("Integration", "MockIntegration")
|
||||||
|
$config.Output.Verbosity = "Detailed"
|
||||||
|
$config.TestResult.Enabled = $true
|
||||||
|
$config.TestResult.OutputFormat = "NUnitXml"
|
||||||
|
$config.TestResult.OutputPath = "TestResults/pester-results.xml"
|
||||||
|
Invoke-Pester -Configuration $config
|
||||||
|
|
||||||
- name: Upload test results
|
- name: Upload test results
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace PSProxmoxVE.Core.Tests.Authentication
|
|||||||
{
|
{
|
||||||
var session = new PveSession(TestHostname, TestPort, false, "root@pam!mytoken=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
|
var session = new PveSession(TestHostname, TestPort, false, "root@pam!mytoken=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
|
||||||
|
|
||||||
Assert.Equal($"https://{TestHostname}:{TestPort}/api2/json", session.BaseUrl);
|
Assert.Equal($"https://{TestHostname}:{TestPort}/api2/json/", session.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
@@ -20,17 +20,20 @@ BeforeAll {
|
|||||||
|
|
||||||
# Find the built module DLL
|
# Find the built module DLL
|
||||||
$dllSearchPaths = @(
|
$dllSearchPaths = @(
|
||||||
(Join-Path $PSScriptRoot '../../PSProxmoxVE.MockServer/bin/Release/net10.0/PSProxmoxVE.MockServer.dll'),
|
(Join-Path $PSScriptRoot '../../PSProxmoxVE.MockServer/bin/Release/net9.0/PSProxmoxVE.MockServer.dll'),
|
||||||
(Join-Path $PSScriptRoot '../../PSProxmoxVE.MockServer/bin/Debug/net10.0/PSProxmoxVE.MockServer.dll')
|
(Join-Path $PSScriptRoot '../../PSProxmoxVE.MockServer/bin/Debug/net9.0/PSProxmoxVE.MockServer.dll')
|
||||||
)
|
)
|
||||||
$mockServerDll = $dllSearchPaths | Where-Object { Test-Path $_ } | Select-Object -First 1
|
$mockServerDll = $dllSearchPaths | Where-Object { Test-Path $_ } | Select-Object -First 1
|
||||||
|
|
||||||
if (-not $mockServerDll) {
|
if (-not $mockServerDll) {
|
||||||
# Build it
|
# Build it
|
||||||
$buildOutput = dotnet build $mockServerProject --configuration Release 2>&1
|
$buildOutput = dotnet build $mockServerProject --configuration Release 2>&1 | Out-String
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
throw "Failed to build mock server (exit code $LASTEXITCODE): $buildOutput"
|
||||||
|
}
|
||||||
$mockServerDll = $dllSearchPaths | Where-Object { Test-Path $_ } | Select-Object -First 1
|
$mockServerDll = $dllSearchPaths | Where-Object { Test-Path $_ } | Select-Object -First 1
|
||||||
if (-not $mockServerDll) {
|
if (-not $mockServerDll) {
|
||||||
throw "Failed to build mock server: $buildOutput"
|
throw "Mock server build succeeded but DLL not found at expected paths: $($dllSearchPaths -join ', ')"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user