diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 141229e..9b30cd9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,9 +16,13 @@ jobs: with: dotnet-version: '9.0.x' - 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 - 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 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 diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index ecbc783..17e6bde 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -217,7 +217,7 @@ jobs: - name: Upload test results if: always() - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v4 with: name: integration-test-results path: TestResults/ diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index cf10e5d..839053f 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -93,14 +93,30 @@ jobs: shell: powershell run: | 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) if: matrix.ps_version != '5.1' shell: pwsh run: | 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 if: always() diff --git a/tests/PSProxmoxVE.Core.Tests/Authentication/PveSessionTests.cs b/tests/PSProxmoxVE.Core.Tests/Authentication/PveSessionTests.cs index af9d753..819a264 100644 --- a/tests/PSProxmoxVE.Core.Tests/Authentication/PveSessionTests.cs +++ b/tests/PSProxmoxVE.Core.Tests/Authentication/PveSessionTests.cs @@ -42,7 +42,7 @@ namespace PSProxmoxVE.Core.Tests.Authentication { 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] diff --git a/tests/PSProxmoxVE.Tests/MockIntegration/MockServer.Tests.ps1 b/tests/PSProxmoxVE.Tests/MockIntegration/MockServer.Tests.ps1 index 571536c..bf95962 100644 --- a/tests/PSProxmoxVE.Tests/MockIntegration/MockServer.Tests.ps1 +++ b/tests/PSProxmoxVE.Tests/MockIntegration/MockServer.Tests.ps1 @@ -20,17 +20,20 @@ BeforeAll { # Find the built module DLL $dllSearchPaths = @( - (Join-Path $PSScriptRoot '../../PSProxmoxVE.MockServer/bin/Release/net10.0/PSProxmoxVE.MockServer.dll'), - (Join-Path $PSScriptRoot '../../PSProxmoxVE.MockServer/bin/Debug/net10.0/PSProxmoxVE.MockServer.dll') + (Join-Path $PSScriptRoot '../../PSProxmoxVE.MockServer/bin/Release/net9.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 if (-not $mockServerDll) { # 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 if (-not $mockServerDll) { - throw "Failed to build mock server: $buildOutput" + throw "Mock server build succeeded but DLL not found at expected paths: $($dllSearchPaths -join ', ')" } }