@@ -6,100 +6,85 @@ Describe "choco headers tests" -Tag Chocolatey, HeadersFeature {
66
77 $Commands = @ (
88 @ {
9- Command = ' apikey'
10- CommandLine = ' list'
9+ CommandArguments = ' apikey' , ' list'
1110 ExpectedHeaders = ' Source|ApiKey'
12- SkipTest = $false
1311 }
1412 @ {
15- Command = ' config'
16- CommandLine = ' list'
13+ CommandArguments = ' config' , ' list'
1714 ExpectedHeaders = ' Name|Value|Description'
18- SkipTest = $false
1915 }
2016 @ {
21- Command = ' feature'
22- CommandLine = ' list'
17+ CommandArguments = ' feature' , ' list'
2318 ExpectedHeaders = ' Name|Enabled|Description'
24- SkipTest = $false
2519 }
2620 @ {
27- Command = ' info'
28- CommandLine = " chocolatey" , " --local-only"
21+ CommandArguments = ' info' , ' chocolatey' , ' --local-only' , ' --pre'
2922 ExpectedHeaders = ' Id|Version'
30- SkipTest = $false
3123 }
3224 @ {
33- Command = ' license'
34- CommandLine = ' info'
35- ExpectedHeaders = ' Name|Type|ExpirationDate|NodeCount'
36- SkipTest = $isLicensed
37- }
38- @ {
39- Command = ' list'
25+ CommandArguments = ' list'
4026 ExpectedHeaders = ' Id|Version'
41- SkipTest = $false
4227 }
4328 @ {
44- Command = ' outdated'
29+ CommandArguments = ' outdated' , ' --ignore-unfound ' , ' --ignore-pinned '
4530 ExpectedHeaders = ' Id|Version|AvailableVersion|Pinned'
46- SkipTest = $false
4731 }
4832 @ {
49- # Needs to pin something...
50- Command = ' pin'
51- CommandLine = ' list'
33+ CommandArguments = ' pin' , ' list'
5234 ExpectedHeaders = ' Id|Version'
53- SkipTest = $false
5435 }
5536 @ {
56- Command = ' rule'
57- CommandLine = ' list'
37+ CommandArguments = ' rule' , ' list'
5838 ExpectedHeaders = ' Severity|Id|Summary|HelpUrl'
59- SkipTest = $false
6039 }
6140 @ {
62- Command = ' search'
63- CommandLine = ' windirstat'
41+ CommandArguments = ' search' , ' windirstat'
6442 ExpectedHeaders = ' Id|Version'
65- SkipTest = $false
6643 }
6744 @ {
68- Command = ' source'
69- CommandLine = ' list'
45+ CommandArguments = ' source' , ' list'
7046 ExpectedHeaders = ' Name|Source|Disabled|UserName|Certificate|Priority|BypassProxy|AllowSelfService|AdminOnly'
71- SkipTest = $false
7247 }
7348 @ {
74- Command = ' template'
75- CommandLine = ' list'
49+ CommandArguments = ' template' , ' list'
7650 ExpectedHeaders = ' Name|Version'
77- SkipTest = $false
7851 }
7952 )
53+
54+ if ($isLicensed ) {
55+ $Commands += @ {
56+ CommandArguments = ' license' , ' info'
57+ ExpectedHeaders = ' Name|Type|ExpirationDate|NodeCount'
58+ }
59+ }
8060 }
8161 BeforeAll {
8262 Initialize-ChocolateyTestInstall
8363
84- New-ChocolateyInstallSnapshot
85-
8664 # These are needed in order to test the choco pin list execution
8765 # as well as the choco apikey list as the headers will only be shown
88- # when there is a pinned package
66+ # when there is a pinned package. Finally, we need to install an
67+ # outdated package, so that the headers show in the choco outdated
68+ # command.
8969 $null = Invoke-Choco pin add -- name= " chocolatey"
9070
91- $null = Invoke-Choco apikey add -- source " https://community.chocolatey.org/api/v2" -- api- key " bob"
71+ $null = Invoke-Choco apikey add -- source " https://test.com/api/add/" -- api- key " test-api-key"
72+
73+ $null = Invoke-Choco install upgradepackage -- version 1.0 .0 -- confirm
74+
75+ New-ChocolateyInstallSnapshot
9276 }
9377
9478 AfterAll {
9579 Remove-ChocolateyTestInstall
9680 }
9781
98- Context " Outputs headers for <Command > when '--include-headers' provided configured" - ForEach $Commands - Skip:( $SkipTest ) {
82+ Context " Outputs headers for <CommandArguments > when '--include-headers' provided configured" - ForEach $Commands {
9983 BeforeAll {
10084 Restore-ChocolateyInstallSnapshot - NoSnapshotCopy
10185
102- $Output = Invoke-Choco $Command @CommandLine -- limit-output -- include- headers
86+ [string []]$chocoArgs = @ ($CommandArguments ) + @ (' --limit-output' , ' --include-headers' )
87+ $Output = Invoke-Choco @chocoArgs
10388 }
10489
10590 It ' Exits success (0)' {
@@ -117,11 +102,12 @@ Describe "choco headers tests" -Tag Chocolatey, HeadersFeature {
117102 }
118103 }
119104
120- Context " Does not output headers for <Command > by default" - ForEach $Commands - Skip:( $SkipTest ) {
105+ Context " Does not output headers for <CommandArguments > by default" - ForEach $Commands {
121106 BeforeAll {
122107 Restore-ChocolateyInstallSnapshot - NoSnapshotCopy
123108
124- $Output = Invoke-Choco $Command @CommandLine -- limit-output
109+ [string []]$chocoArgs = @ ($CommandArguments ) + @ (' --limit-output' )
110+ $Output = Invoke-Choco @chocoArgs
125111 }
126112
127113 It ' Exits success (0)' {
@@ -139,16 +125,17 @@ Describe "choco headers tests" -Tag Chocolatey, HeadersFeature {
139125 }
140126 }
141127
142- Context " Includes headers when feature enabled" - Skip:( $SkipTest ) {
128+ Context " Includes headers when feature enabled" {
143129 BeforeAll {
144130 Restore-ChocolateyInstallSnapshot
145131
146132 Enable-ChocolateyFeature - Name AlwaysIncludeHeaders
147133 }
148134
149- Context " Includes headers for <Command >" - ForEach $Commands {
135+ Context " Includes headers for <CommandArguments >" - ForEach $Commands {
150136 BeforeAll {
151- $Output = Invoke-Choco $Command @CommandLine -- limit-output
137+ [string []]$chocoArgs = @ ($CommandArguments ) + @ (' --limit-output' )
138+ $Output = Invoke-Choco @chocoArgs
152139 }
153140
154141 It ' Exits success (0)' {
0 commit comments