|
| 1 | +# This file contains test cases for https://pester.dev/ |
| 2 | +Set-StrictMode -Version Latest |
| 3 | +$ErrorActionPreference = 'Stop' |
| 4 | + |
| 5 | +Describe 'Publish' { |
| 6 | + BeforeAll { |
| 7 | + $package = Get-ChildItem -Path "$PSScriptRoot/../src/Sentry/bin/Release/Sentry.*.nupkg" -File | Select-Object -First 1 |
| 8 | + if (-not $package) |
| 9 | + { |
| 10 | + throw "No NuGet package found in src/Sentry/bin/Release." |
| 11 | + } |
| 12 | + |
| 13 | + $tempDir = Resolve-Path ([System.IO.Path]::GetTempPath()) |
| 14 | + $tempDir = Join-Path $tempDir ([System.IO.Path]::GetRandomFileName()) |
| 15 | + New-Item -ItemType Directory -Path $tempDir -Force | Out-Null |
| 16 | + Set-Location $tempDir |
| 17 | + Write-Host "Testing $package in $tempDir" |
| 18 | + |
| 19 | + Write-Host "::group::Setup local NuGet source" |
| 20 | + $localPackages = Join-Path $tempDir "packages" |
| 21 | + New-Item -ItemType Directory -Path $localPackages -Force | Out-Null |
| 22 | + Copy-Item $package $localPackages |
| 23 | + $localConfig = Join-Path $tempDir "nuget.config" |
| 24 | + Copy-Item $PSScriptRoot/nuget.config $localConfig |
| 25 | + (Get-Content $localConfig) -replace '\./packages', $localPackages | Set-Content $localConfig |
| 26 | + $env:NUGET_PACKAGES = Join-Path $tempDir "nuget" |
| 27 | + New-Item -ItemType Directory -Path $env:NUGET_PACKAGES -Force | Out-Null |
| 28 | + dotnet nuget list source | Write-Host |
| 29 | + Write-Host "::endgroup::" |
| 30 | + |
| 31 | + Write-Host "::group::Create test project" |
| 32 | + dotnet new console --aot --name hello-sentry --output . | Write-Host |
| 33 | + dotnet add package Sentry --prerelease --source $localPackages | Write-Host |
| 34 | + @" |
| 35 | +SentrySdk.Init(options => |
| 36 | +{ |
| 37 | + options.Dsn = "https://foo@sentry.invalid/42"; |
| 38 | + options.Debug = true; |
| 39 | +}); |
| 40 | +Console.WriteLine("Hello, Sentry!"); |
| 41 | +"@ | Set-Content Program.cs |
| 42 | + Write-Host "::endgroup::" |
| 43 | + } |
| 44 | + |
| 45 | + AfterAll { |
| 46 | + if ($tempDir -and (Test-Path $tempDir)) |
| 47 | + { |
| 48 | + Remove-Item $tempDir -Recurse -Force -ErrorAction SilentlyContinue |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + It 'Aot' { |
| 53 | + dotnet publish -c Release | Write-Host |
| 54 | + $LASTEXITCODE | Should -Be 0 |
| 55 | + |
| 56 | + $tfm = (Get-ChildItem -Path "bin/Release" -Directory | Select-Object -First 1).Name |
| 57 | + $rid = (Get-ChildItem -Path "bin/Release/$tfm" -Directory | Select-Object -First 1).Name |
| 58 | + & "bin/Release/$tfm/$rid/publish/hello-sentry" | Write-Host |
| 59 | + $LASTEXITCODE | Should -Be 0 |
| 60 | + } |
| 61 | + |
| 62 | + It 'Container' -Skip:(!$IsLinux -or !(Get-Command docker -ErrorAction SilentlyContinue)) { |
| 63 | + dotnet publish -p:EnableSdkContainerSupport=true -t:PublishContainer | Write-Host |
| 64 | + $LASTEXITCODE | Should -Be 0 |
| 65 | + |
| 66 | + docker run --rm hello-sentry | Write-Host |
| 67 | + $LASTEXITCODE | Should -Be 0 |
| 68 | + } |
| 69 | +} |
0 commit comments