Skip to content

Commit

Permalink
Add test case for NSIS installer
Browse files Browse the repository at this point in the history
  • Loading branch information
niheaven committed May 9, 2024
1 parent 6259fb2 commit b7a6feb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
18 changes: 17 additions & 1 deletion test/Scoop-Decompress.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Describe 'Decompression function' -Tag 'Scoop', 'Windows', 'Decompress' {
}
It 'Test cases should exist and hash should match' {
$testcases | Should -Exist
(Get-FileHash -Path $testcases -Algorithm SHA256).Hash.ToLower() | Should -Be 'ba6f14687d1c9ec785dc2030416ff4e456358a7b3a403982c4b7baa247477146'
(Get-FileHash -Path $testcases -Algorithm SHA256).Hash.ToLower() | Should -Be '23a23a63e89ff95f5ef27f0cacf08055c2779cf41932266d8f509c2e200b8b63'
}
It 'Test cases should be extracted correctly' {
{ Microsoft.PowerShell.Archive\Expand-Archive -Path $testcases -DestinationPath $working_dir } | Should -Not -Throw
Expand All @@ -50,6 +50,7 @@ Describe 'Decompression function' -Tag 'Scoop', 'Windows', 'Decompress' {
$test6_1 = "$working_dir\7ZipTest6.part01.rar"
$test6_2 = "$working_dir\7ZipTest6.part02.rar"
$test6_3 = "$working_dir\7ZipTest6.part03.rar"
$test7 = "$working_dir\NSISTest.exe"
}

AfterEach {
Expand Down Expand Up @@ -112,6 +113,21 @@ Describe 'Decompression function' -Tag 'Scoop', 'Windows', 'Decompress' {
(Get-ChildItem $to).Count | Should -Be 1
}

It 'extract NSIS installer' {
$to = test_extract 'Expand-7zipArchive' $test7
$to | Should -Exist
"$to\empty" | Should -Exist
(Get-ChildItem $to).Count | Should -Be 1
}

It 'self-extract NSIS installer' {
$to = "$working_dir\NSIS Test"
$null = Invoke-ExternalCommand -FilePath $test7 -ArgumentList @('/S', '/NCRC', "/D=$to")
$to | Should -Exist
"$to\empty" | Should -Exist
(Get-ChildItem $to).Count | Should -Be 1
}

It 'works with "-Removal" switch ($removal param)' {
$test1 | Should -Exist
$to = test_extract 'Expand-7zipArchive' $test1 $true
Expand Down
4 changes: 2 additions & 2 deletions test/Scoop-TestLib.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# copies fixtures to a working directory
function setup_working($name) {
$fixtures = "$PSScriptRoot/fixtures/$name"
$fixtures = "$PSScriptRoot\fixtures\$name"
if (!(Test-Path $fixtures)) {
Write-Host "couldn't find fixtures for $name at $fixtures" -f red
exit 1
}

# reset working dir
$working_dir = "$([IO.Path]::GetTempPath())ScoopTestFixtures/$name"
$working_dir = "$([IO.Path]::GetTempPath())ScoopTestFixtures\$name"

if (Test-Path $working_dir) {
Remove-Item -Recurse -Force $working_dir
Expand Down
Binary file modified test/fixtures/decompress/TestCases.zip
Binary file not shown.

0 comments on commit b7a6feb

Please sign in to comment.