Created
January 29, 2024 17:14
-
-
Save lucax88x/d22eae416580d274e1ed771bdb14a3d8 to your computer and use it in GitHub Desktop.
nuget.tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(-not (Get-Module Pester -ListAvailable)) | |
{ | |
Install-Module Pester | |
} | |
Import-Module Pester -Passthru | |
$DebugPreference = "Continue" | |
Describe 'Nuget' { | |
BeforeAll { | |
$nugets = @( | |
'MessagePack 1.8.0', | |
'Microsoft.Extensions.Logging 6.0.0', | |
'Grpc.Core 2.46.2', | |
'Grpc.Core.Api 2.45.0', | |
'Microsoft.NET.Sdk.Maui.Manifest-6.0.300 6.0.419+10-sha.db197ebd4-azdo.6404918', | |
'Radzen.Blazor 3.20.5' | |
) | |
. $PSScriptRoot/Nuget.ps1 | |
} | |
It "Should not filter" { | |
$result = FilterNugetPackages $nugets | |
$result.Count | Should -Be 6 | |
} | |
It "Should filter with only include" { | |
$result = FilterNugetPackages $nugets -Include "Grpc.*" | |
$result.Count | Should -Be 2 | |
$result[0] | Should -Be "Grpc.Core 2.46.2" | |
$result[1] | Should -Be "Grpc.Core.Api 2.45.0" | |
} | |
It "Should filter with only exclude" { | |
$result = FilterNugetPackages $nugets -Exclude "MessagePack.*" | |
Write-Debug "got $($result)" | |
Write-Debug "type: $($result.GetType())" | |
Write-Debug "count: $($result.Count)" | |
Write-Debug "first: $($result[0])" | |
$result.Count | Should -Be 5 | |
$result[0] | Should -Be "Microsoft.Extensions.Logging 6.0.0" | |
$result[1] | Should -Be "Grpc.Core 2.46.2" | |
$result[2] | Should -Be "Grpc.Core.Api 2.45.0" | |
$result[3] | Should -Be "Microsoft.NET.Sdk.Maui.Manifest-6.0.300 6.0.419+10-sha.db197ebd4-azdo.6404918" | |
$result[4] | Should -Be "Radzen.Blazor 3.20.5" | |
} | |
It "Should filter with include and exclude" { | |
$result = FilterNugetPackages $nugets -Include "Grpc.*" -Exclude "Grpc.Core.Api" | |
Write-Debug "got $($result)" | |
Write-Debug "type: $($result.GetType())" | |
Write-Debug "count: $($result.Count)" | |
Write-Debug "first: $($result[0])" | |
$result.Count | Should -Be 1 | |
$result[0] | Should -Be "Grpc.Core 2.46.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment