From 8514c941e1aac07b6566fb4ed47adb2e4175c529 Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Tue, 19 Dec 2023 17:52:25 -0800 Subject: [PATCH 1/2] (tests) Move the Pester tests to be consistent The pester tests in the rest of the Chocolatey repositories reside in a tests/pester-tests directory. This moves the tests to be consistent with the other repositories. --- Tests/{ => pester-tests}/chocolateyguicli.Tests.ps1 | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Tests/{ => pester-tests}/chocolateyguicli.Tests.ps1 (100%) diff --git a/Tests/chocolateyguicli.Tests.ps1 b/Tests/pester-tests/chocolateyguicli.Tests.ps1 similarity index 100% rename from Tests/chocolateyguicli.Tests.ps1 rename to Tests/pester-tests/chocolateyguicli.Tests.ps1 From 8d431e92463b70337fc7b422e0748bbd2b0ed63c Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Tue, 19 Dec 2023 17:54:29 -0800 Subject: [PATCH 2/2] (tests) Update Pester tests to be consistent --- Tests/pester-tests/chocolateyguicli.Tests.ps1 | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Tests/pester-tests/chocolateyguicli.Tests.ps1 b/Tests/pester-tests/chocolateyguicli.Tests.ps1 index 44a013870..393001fad 100644 --- a/Tests/pester-tests/chocolateyguicli.Tests.ps1 +++ b/Tests/pester-tests/chocolateyguicli.Tests.ps1 @@ -1,4 +1,4 @@ -Import-Module ./helpers/gui-helpers.psm1 +Import-Module ../helpers/gui-helpers.psm1 Describe "chocolateyguicli" -Tag ChocolateyGuiCli { BeforeDiscovery { @@ -29,20 +29,21 @@ Describe "chocolateyguicli" -Tag ChocolateyGuiCli { $Output.String | Should -Match $Name } } - + Context "Toggles the feature (<_.Name>) successfully" -ForEach $Features { BeforeAll { - $Outputs = if ($Enabled) { - Invoke-GuiCli feature disable --name $_.Name - Invoke-GuiCli feature enable --name $_.Name + if ($Enabled) { + $DisableOutput = Invoke-GuiCli feature disable --name $_.Name + $EnableOutput = Invoke-GuiCli feature enable --name $_.Name } else { - Invoke-GuiCli feature enable --name $_.Name - Invoke-GuiCli feature disable --name $_.Name + $EnableOutput = Invoke-GuiCli feature enable --name $_.Name + $DisableOutput = Invoke-GuiCli feature disable --name $_.Name } } - It "Should exit success" { - $Outputs.ExitCode | Should -Not -Contain 1 + It "Should exit success (0)" { + $EnableOutput.ExitCode | Should -Be 0 -Because $EnableOutput.String + $DisableOutput.ExitCode | Should -Be 0 -Because $DisableOutput.String } } }