Skip to content

Commit

Permalink
Merge pull request chocolatey#2824 from AdmiringWorm/logging-tests
Browse files Browse the repository at this point in the history
(chocolatey#1332) Add tests for disabling file logging of archive extractions
  • Loading branch information
corbob authored Sep 22, 2022
2 parents aa184b3 + 13968e9 commit 097b52f
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Invoke-Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ try {
Verbosity = 'Minimal'
}
Filter = @{
ExcludeTag = 'Background', 'Licensed', 'CCM', 'WIP', 'NonAdmin'
ExcludeTag = 'Background', 'Licensed', 'CCM', 'WIP', 'NonAdmin', 'Internal'
}
}

Expand Down
32 changes: 32 additions & 0 deletions tests/chocolatey-tests/choco-install.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1392,4 +1392,36 @@ Describe "choco install" -Tag Chocolatey, InstallCommand {
$result2.Lines | Should -Contain "Circular dependency detected 'circulardependency2 0.0.1 => circulardependency1 0.0.1 => circulardependency2 0.0.1'."
}
}

Context "Installing package that extracts local zip archive while disabling logging" {
BeforeAll {
Restore-ChocolateyInstallSnapshot

$Output = Invoke-Choco install zip-log-disable-test --verbose --debug -y
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
}

It "Does not output extracted file path '<_>'" -ForEach @('tools\'; 'tools\chocolateybeforemodify.ps1'; 'tools\chocolateyinstall.ps1'; 'tools\chocolateyuninstall.ps1'; 'zip-log-disable-test.nuspec') {
$Output.String | Should -Not -Match "- $([regex]::Escape($_))"
}
}

Context "Installing package that extracts external zip archive while disabling logging" -Tag Internal {
BeforeAll {
Restore-ChocolateyInstallSnapshot

$Output = Invoke-Choco install zip-log-disable-test-external --verbose --debug -y
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
}

It "Does not output extracted file path '<_>'" -ForEach @('tools\'; 'tools\chocolateybeforemodify.ps1'; 'tools\chocolateyinstall.ps1'; 'tools\chocolateyuninstall.ps1'; 'zip-log-disable-test.nuspec') {
$Output.String | Should -Not -Match "- $([regex]::Escape($_))"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

$ErrorActionPreference = 'Stop';
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"

$packageArgs = @{
packageName = $env:ChocolateyPackageName
destination = "$toolsDir\extraction"
file = "$toolsDir\zip-log-disable-test.zip"
disableLogging= $true
}

Get-ChocolateyUnzip @packageArgs
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>zip-log-disable-test</id>
<version>1.0.0</version>
<title>zip-log-disable-test (Install)</title>
<authors>__REPLACE_AUTHORS_OF_SOFTWARE_COMMA_SEPARATED__</authors>
<tags>zip-log-disable-test SPACE_SEPARATED</tags>
<description>Package used to test disabling verbose file log for zip extraction</description>
</metadata>
<files>
<file src="tools\**" target="tools" />
</files>
</package>

0 comments on commit 097b52f

Please sign in to comment.