Skip to content

Commit

Permalink
feat(tests):add Get-ReleaseAsset tests
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmckendry committed May 19, 2024
1 parent b73fef5 commit 1a5ff2c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions ps-arch-wsl/ps-arch-wsl.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BeforeAll {
Import-Module $PSScriptRoot/ps-arch-wsl.psm1 -Force
}

Describe "Get-ReleaseAsset" {
It "Finds the release asset" {
InModuleScope ps-arch-wsl {
$foundAsset = Get-ReleaseAsset -Repository "yuk7/ArchWSL" -AssetFilter "cer"
$latestCertificateInTemp = Get-ChildItem $env:Temp | Where-Object { $_.FullName -like "*.cer" } | Sort-Object -Property CreationTime -Descending
$foundAsset | Should -Be $latestCertificateInTemp[0].FullName
}
}

It "Can't find the release asset" {
InModuleScope ps-arch-wsl {
$repository = "yuk7/ArchWSL"
$filter = "someNonExistentExt"
{ Get-ReleaseAsset -Repository $repository -AssetFilter $filter } | Should -Throw -ExpectedMessage "Failed to find an asset matching the filter '$filter' from the latest release of $repository."
}
}

It "Can't find the repository" {
InModuleScope ps-arch-wsl {
$repository = "scottmckendry/norepositoryhere"
$filter = "doesntmatter"
{ Get-ReleaseAsset -Repository $repository -AssetFilter $filter } | Should -Throw -ExpectedMessage "$repository doesn't exist or has no releases."
}
}
}

0 comments on commit 1a5ff2c

Please sign in to comment.