Files
runner-images/images/ubuntu/scripts/tests/DotnetSDK.Tests.ps1
Shamil Mubarakshin dbb10c67ba [ubuntu] Refactor pester tests (#9006)
* [ubuntu] Refactor pester tests

* Fix key name and add BeforeAll

* Fix ActionArchiveCache test
2023-12-14 17:33:34 +01:00

41 lines
1.3 KiB
PowerShell

Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Describe "Dotnet and tools" {
BeforeAll {
$env:PATH = "/etc/skel/.dotnet/tools:$($env:PATH)"
$dotnetSDKs = dotnet --list-sdks | ConvertTo-Json
$dotnetRuntimes = dotnet --list-runtimes | ConvertTo-Json
}
$dotnetVersions = (Get-ToolsetContent).dotnet.versions
Context "Default" {
It "Default Dotnet SDK is available" {
"dotnet --version" | Should -ReturnZeroExitCode
}
}
foreach ($version in $dotnetVersions) {
Context "Dotnet $version" {
$dotnet = @{ dotnetVersion = $version }
It "SDK <dotnetVersion> is available" -TestCases $dotnet {
$dotnetSDKs | Should -Match "$dotnetVersion.[1-9]*"
}
It "Runtime <dotnetVersion> is available" -TestCases $dotnet {
$dotnetRuntimes | Should -Match "$dotnetVersion.[1-9]*"
}
}
}
Context "Dotnet tools" {
$dotnetTools = (Get-ToolsetContent).dotnet.tools
$testCases = $dotnetTools | ForEach-Object { @{ ToolName = $_.name; TestInstance = $_.test }}
It "<ToolName> is available" -TestCases $testCases {
"$TestInstance" | Should -ReturnZeroExitCode
}
}
}