Skip to content

Commit 2cdf159

Browse files
authored
Merge pull request #3854 from corbob/add-regression-tests
(#3853) Copy NuGet Extraction tests from support branch to develop
2 parents 511b451 + 9fa722f commit 2cdf159

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Import-Module helpers/common-helpers
2+
3+
# These tests are skipped when not in Test Kitchen as the packages for this test are not available in this repository.
4+
# These tests also modify files outside of the tests.
5+
Describe "Extraction tests <_> command" -Skip:(-not $env:TEST_KITCHEN) -ForEach @(
6+
'install'
7+
'upgrade'
8+
if (Test-PackageIsEqualOrHigher -PackageName chocolatey.extension -Version 5.0.0) {
9+
'download'
10+
}
11+
) -Tag Extraction {
12+
BeforeDiscovery {
13+
$Type = @(
14+
'combined-extracted-path'
15+
'absolute-extracted-path'
16+
'relative-extracted-path'
17+
)
18+
}
19+
20+
BeforeAll {
21+
Initialize-ChocolateyTestInstall
22+
New-ChocolateyInstallSnapshot
23+
$Command = $_
24+
}
25+
26+
AfterAll {
27+
Remove-ChocolateyTestInstall
28+
}
29+
30+
Context '<_> extraction' -ForEach $Type {
31+
BeforeAll {
32+
Restore-ChocolateyInstallSnapshot
33+
34+
$Output = Invoke-Choco $Command $_ --confirm
35+
}
36+
37+
AfterAll {
38+
Remove-Item -Path C:\demonstration -Force -Recurse -ErrorAction SilentlyContinue
39+
}
40+
41+
It 'Exits correctly' {
42+
$Output.ExitCode | Should -Be 1 -Because $Output.String
43+
}
44+
45+
It 'Should output correctly' {
46+
$Output.String | Should -Match "The package '$_.1.0.0' contains an entry '.*' which is unsafe for extraction."
47+
}
48+
49+
It 'Should not create the file.' {
50+
'C:\demonstration\demo.txt' | Should -Not -Exist -Because $Output.String
51+
}
52+
53+
}
54+
}

0 commit comments

Comments
 (0)