From 7cc1a7cbb17d0be92cd449465fd184f15a17682d Mon Sep 17 00:00:00 2001 From: Rain Sallow Date: Wed, 24 May 2023 14:18:37 -0400 Subject: [PATCH] (#158) Update tests --- .../commands/choco-list.Tests.ps1 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/chocolatey-tests/commands/choco-list.Tests.ps1 b/tests/chocolatey-tests/commands/choco-list.Tests.ps1 index bc29af4518..3969967eab 100644 --- a/tests/chocolatey-tests/commands/choco-list.Tests.ps1 +++ b/tests/chocolatey-tests/commands/choco-list.Tests.ps1 @@ -101,15 +101,27 @@ Describe "choco list" -Tag Chocolatey, ListCommand { Context "Listing local packages with unsupported argument outputs warning" -ForEach @('-l', '-lo', '--lo', '--local', '--localonly', '--local-only', '--order-by-popularity', '-a', '--all', '--allversions', '--all-versions', '-li', '-il', '-lai', '-lia', '-ali', '-ail', '-ial', '-ila') { BeforeAll { + $LogPath = "$env:ChocolateyInstall\logs\chocolatey.log" + $OldLogContent = Get-Content $LogPath + Remove-Item -Path $LogPath + $Output = Invoke-Choco list $_ + $LogFile = Get-Content -Path $LogPath + + # Logs are picked up by CI for investigation if needed, so we'll keep both full sets of logs. + @( + $OldLogContent + $LogFile + ) | Set-Content -Path $LogPath } It "Exits with Success (0)" { $Output.ExitCode | Should -Be 0 } - It "Should contain expected warning message" { - $Output.Lines | Should -Contain "UNSUPPORTED ARGUMENT: Ignoring the argument $_. This argument is unsupported for locally installed packages, and will be treated as a package name in Chocolatey CLI v3!" + It "Should contain expected warning message in the logs" { + @($LogFile) -match "Ignoring the argument $_. This argument is unsupported for locally installed packages." | + Should -Not -BeNullOrEmpty } } }