@@ -199,6 +199,123 @@ Describe "choco install" -Tag Chocolatey, InstallCommand {
199
199
It " Outputs a message indicating that missingpackage was not installed" {
200
200
$Output.Lines | Should - Contain " missingpackage not installed. The package was not found with the source(s) listed."
201
201
}
202
+
203
+ Context " packages.config containing all options" {
204
+ BeforeAll {
205
+ @"
206
+ <?xml version="1.0" encoding="utf-8"?>
207
+ <packages>
208
+ <package
209
+ id="installpackage"
210
+ prerelease="true"
211
+ overrideArguments="true"
212
+ notSilent="true"
213
+ allowDowngrade="true"
214
+ forceDependencies="true"
215
+ skipAutomationScripts="true"
216
+ user="user"
217
+ password="string"
218
+ cert="cert"
219
+ certPassword="string"
220
+ ignoreChecksums="true"
221
+ allowEmptyChecksums="true"
222
+ allowEmptyChecksumsSecure="true"
223
+ requireChecksums="true"
224
+ downloadChecksum="downloadChecksum"
225
+ downloadChecksum64="downloadChecksum64"
226
+ downloadChecksumType="downloadChecksumType"
227
+ downloadChecksumType64="downloadChecksumType64"
228
+ ignorePackageExitCodes="true"
229
+ usePackageExitCodes="true"
230
+ stopOnFirstFailure="true"
231
+ exitWhenRebootDetected="true"
232
+ ignoreDetectedReboot="true"
233
+ disableRepositoryOptimizations="true"
234
+ acceptLicense="true"
235
+ confirm="true"
236
+ limitOutput="true"
237
+ cacheLocation="Z:\"
238
+ failOnStderr="true"
239
+ useSystemPowershell="true"
240
+ noProgress="true"
241
+ force="true"
242
+ executionTimeout="1000"
243
+ />
244
+ </packages>
245
+ "@ | Out-File $env: CHOCOLATEY_TEST_PACKAGES_PATH \alloptions.packages.config - Encoding utf8
246
+
247
+ $Output = Invoke-Choco install $env: CHOCOLATEY_TEST_PACKAGES_PATH \alloptions.packages.config -- confirm -- verbose -- debug
248
+
249
+ # This is based on two observations: The addition explicitly outputs that it's the Package Configuration.
250
+ # The configuration output is also about 80 lines.
251
+ $StartofPackageConfiguration = [array ]::IndexOf($Output.Lines , " Package Configuration: CommandName='install'|" )
252
+ $PackageConfigurationOutput = $Output.Lines [$StartofPackageConfiguration .. ($StartofPackageConfiguration + 80 )] -join [Environment ]::NewLine
253
+ }
254
+
255
+ # We are explicitly passing in a bad username and password here.
256
+ # Therefore it cannot find the package to install and fails the install.
257
+ # That doesn't matter because we just need to test that the configuration is set properly.
258
+ It " Should exit Failure (1)" {
259
+ $Output.ExitCode | Should - Be 1 - Because $Output.String
260
+ }
261
+
262
+ It " Should contain the expected configuration option (<Option>) set correctly (<ExpectedValue>)" - ForEach @ (
263
+ @ { Option = " Prerelease" ; ExpectedValue = " True" }
264
+ @ { Option = " OverrideArguments" ; ExpectedValue = " True" }
265
+ @ { Option = " NotSilent" ; ExpectedValue = " True" }
266
+ @ { Option = " AllowDowngrade" ; ExpectedValue = " True" }
267
+ @ { Option = " ForceDependencies" ; ExpectedValue = " True" }
268
+ # SkipAutomationScripts sets configuration option SkipPackageInstallProvider
269
+ @ { Option = " SkipPackageInstallProvider" ; ExpectedValue = " True" }
270
+ # User is expanded to Username
271
+ @ { Option = " Username" ; ExpectedValue = " user" }
272
+ # Password should *not* be output in the logging
273
+ # @{ Option = "Password" ; ExpectedValue = "string" }
274
+ # Cert is expanded to Certificate
275
+ @ { Option = " Certificate" ; ExpectedValue = " cert" }
276
+ # CertPassword should *not* be output in the logging
277
+ # @{ Option = "CertPassword" ; ExpectedValue = "string" }
278
+ # IgnoreChecksums sets ChecksumFiles to False
279
+ @ { Option = " ChecksumFiles" ; ExpectedValue = " False" }
280
+ # RequireChecksums is evaluated after allowing empty. It sets both allow options to False
281
+ # @{ Option = "RequireChecksums" ; ExpectedValue = "True" }
282
+ @ { Option = " AllowEmptyChecksums" ; ExpectedValue = " False" }
283
+ @ { Option = " AllowEmptyChecksumsSecure" ; ExpectedValue = " False" }
284
+ @ { Option = " DownloadChecksum" ; ExpectedValue = " downloadChecksum" }
285
+ @ { Option = " DownloadChecksum64" ; ExpectedValue = " downloadChecksum64" }
286
+ @ { Option = " DownloadChecksumType" ; ExpectedValue = " downloadChecksumType" }
287
+ @ { Option = " DownloadChecksumType64" ; ExpectedValue = " downloadChecksumType64" }
288
+ # UsePackageExitCodes and IgnorePackageExitCodes set the same setting, but are opposite of each other.
289
+ # UsePackageExitCodes is evaluated last, so takes precidence.
290
+ # @{ Option = "IgnorePackageExitCodes" ; ExpectedValue = "True" }
291
+ @ { Option = " UsePackageExitCodes" ; ExpectedValue = " True" }
292
+ # StopOnFirstFailure is expanded to StopOnFirstPackageFailure
293
+ @ { Option = " StopOnFirstPackageFailure" ; ExpectedValue = " True" }
294
+ # ExitWhenRebootDetected and IgnoreDetectedReboot both set ExitOnRebootDetected.
295
+ # IgnoreDetectedReboot is evaluated last, so takes precidence.
296
+ # @{ Option = "ExitWhenRebootDetected" ; ExpectedValue = "True" }
297
+ # @{ Option = "IgnoreDetectedReboot" ; ExpectedValue = "True" }
298
+ @ { Option = " ExitOnRebootDetected" ; ExpectedValue = " False" }
299
+ # DisableRepositoryOptimizations sets UsePackageRepositoryOptimizations to false
300
+ @ { Option = " UsePackageRepositoryOptimizations" ; ExpectedValue = " False" }
301
+ @ { Option = " AcceptLicense" ; ExpectedValue = " True" }
302
+ # Confirm is negated into PromptForConfirmation
303
+ @ { Option = " PromptForConfirmation" ; ExpectedValue = " False" }
304
+ # LimitOutput is negated into Regular Output
305
+ @ { Option = " RegularOutput" ; ExpectedValue = " False" }
306
+ @ { Option = " CacheLocation" ; ExpectedValue = " Z:\\" }
307
+ @ { Option = " FailOnStandardError" ; ExpectedValue = " True" }
308
+ # UseSystemPowerShell sets UsePowerShellHost to False
309
+ @ { Option = " UsePowerShellHost" ; ExpectedValue = " False" }
310
+ # NoProgress sets ShowDownloadProgress to False
311
+ @ { Option = " ShowDownloadProgress" ; ExpectedValue = " False" }
312
+ @ { Option = " Force" ; ExpectedValue = " True" }
313
+ # ExecutionTimeout is expanded to CommandExecutionTimeoutSeconds
314
+ @ { Option = " CommandExecutionTimeoutSeconds" ; ExpectedValue = " 1000" }
315
+ ) {
316
+ $PackageConfigurationOutput | Should -Match " $Option ='$ExpectedValue '"
317
+ }
318
+ }
202
319
}
203
320
204
321
Context " Installing a Package that is already installed" {
0 commit comments