From 8dd60c91c2e318047ba5ec307fe8de1ee411079d Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Wed, 27 Sep 2023 10:34:36 -0700 Subject: [PATCH 01/37] (maint) rename tests from chocolatey-tests This commit renames the Pester tests directory from chocolatey-tests to pester-tests. This allows our script to pull consistently from all of our repositories without worrying about which repository it's coming from. --- .../BundledApplications.Tests.ps1 | 0 .../TestCertificate.pfx | Bin .../chocolatey.Tests.ps1 | 0 .../chocolateyProfile.Tests.ps1 | 0 .../commands/choco-apikey.Tests.ps1 | 0 .../commands/choco-config.Tests.ps1 | 0 .../commands/choco-export.Tests.ps1 | 0 .../commands/choco-feature.Tests.ps1 | 0 .../commands/choco-help.Tests.ps1 | 0 .../commands/choco-info.Tests.ps1 | 0 .../commands/choco-install.Tests.ps1 | 0 .../commands/choco-list.Tests.ps1 | 0 .../commands/choco-new.Tests.ps1 | 0 .../commands/choco-outdated.Tests.ps1 | 0 .../commands/choco-pack.Tests.ps1 | 0 .../commands/choco-pin.Tests.ps1 | 0 .../commands/choco-push.Tests.ps1 | 0 .../commands/choco-removed.Tests.ps1 | 0 .../commands/choco-search.Tests.ps1 | 0 .../commands/choco-source.Tests.ps1 | 0 .../commands/choco-template.Tests.ps1 | 0 .../commands/choco-uninstall.Tests.ps1 | 0 .../commands/choco-upgrade.Tests.ps1 | 0 .../commands/choco-version.Tests.ps1 | 0 .../basic-dependencies/basic-dependencies.nuspec | 0 .../commands/testnuspecs/basic/basic.nuspec | 0 .../commands/testnuspecs/basic/tools/purpose.txt | 0 .../commands/testnuspecs/cdata/cdata.nuspec | 0 .../commands/testnuspecs/description-long.nuspec | 0 .../empty-requireLicenseAcceptance.nuspec | 0 .../commands/testnuspecs/empty.nuspec | 0 .../testnuspecs/forward-slash/forward-slash.nuspec | 0 .../testnuspecs/forward-slash/tools/purpose.txt | 0 .../commands/testnuspecs/full/full.nuspec | 0 .../commands/testnuspecs/full/tools/purpose.txt | 0 .../testnuspecs/invalid-bugtrackerurl.nuspec | 0 .../testnuspecs/invalid-character-and.nuspec | 0 .../testnuspecs/invalid-character-lesser.nuspec | 0 .../commands/testnuspecs/invalid-docsurl.nuspec | 0 .../commands/testnuspecs/invalid-iconurl.nuspec | 0 .../commands/testnuspecs/invalid-id.nuspec | 0 .../commands/testnuspecs/invalid-licenseUrl.nuspec | 0 .../testnuspecs/invalid-mailinglisturl.nuspec | 0 .../commands/testnuspecs/invalid-no-content.nuspec | 0 .../testnuspecs/invalid-projectsourceurl.nuspec | 0 .../commands/testnuspecs/invalid-projecturl.nuspec | 0 .../invalid-requireLicenseAcceptance.nuspec | 0 .../commands/testnuspecs/invalid-version.nuspec | 0 .../commands/testnuspecs/missing.nuspec | 0 .../commands/testnuspecs/required.nuspec | 0 .../commands/testpackages/.gitignore | 0 .../1.0.0/chocolatey-dummy-package.nuspec | 0 .../installpackage/1.0.0/installpackage.nuspec | 0 .../1.0.0/tools/Casemismatch.exe.ignore | 0 .../installpackage/1.0.0/tools/casemismatch.exe | 0 .../1.0.0/tools/chocolateyBeforeModify.ps1 | 0 .../1.0.0/tools/chocolateyinstall.ps1 | 0 .../1.0.0/tools/chocolateyuninstall.ps1 | 0 .../installpackage/1.0.0/tools/console.exe | 0 .../installpackage/1.0.0/tools/graphical.exe | 0 .../installpackage/1.0.0/tools/graphical.exe.gui | 0 .../installpackage/1.0.0/tools/not.installed.exe | 0 .../1.0.0/tools/not.installed.exe.ignore | 0 .../1.0.0/packagewithscript.nuspec | 0 .../1.0.0/tools/chocolateyBeforeModify.ps1 | 0 .../1.0.0/tools/chocolateyinstall.ps1 | 0 .../1.0.0/tools/chocolateyuninstall.ps1 | 0 .../1.0.0/too-long-description.nuspec | 0 .../too-long-title/1.0.0/too-long-title.nuspec | 0 .../tools/chocolateyinstall.ps1 | 0 .../tools/zip-log-disable-test.zip | Bin .../zip-log-disable-test.nuspec | 0 .../features/ChocolateyCache.Tests.ps1 | 0 .../features/ChocolateyFunctions.Tests.ps1 | 0 .../features/EnvironmentVariables.Tests.ps1 | 0 .../features/Hooks.Tests.ps1 | 0 .../features/Proxy.Tests.ps1 | 0 .../features/PythonSource.Tests.ps1 | 0 78 files changed, 0 insertions(+), 0 deletions(-) rename tests/{chocolatey-tests => pester-tests}/BundledApplications.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/TestCertificate.pfx (100%) rename tests/{chocolatey-tests => pester-tests}/chocolatey.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/chocolateyProfile.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-apikey.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-config.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-export.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-feature.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-help.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-info.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-install.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-list.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-new.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-outdated.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-pack.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-pin.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-push.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-removed.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-search.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-source.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-template.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-uninstall.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-upgrade.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/choco-version.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/basic-dependencies/basic-dependencies.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/basic/basic.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/basic/tools/purpose.txt (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/cdata/cdata.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/description-long.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/empty-requireLicenseAcceptance.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/empty.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/forward-slash/forward-slash.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/forward-slash/tools/purpose.txt (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/full/full.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/full/tools/purpose.txt (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/invalid-bugtrackerurl.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/invalid-character-and.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/invalid-character-lesser.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/invalid-docsurl.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/invalid-iconurl.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/invalid-id.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/invalid-licenseUrl.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/invalid-mailinglisturl.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/invalid-no-content.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/invalid-projectsourceurl.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/invalid-projecturl.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/invalid-requireLicenseAcceptance.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/invalid-version.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/missing.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testnuspecs/required.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/.gitignore (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/chocolatey-dummy-package/1.0.0/chocolatey-dummy-package.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/installpackage/1.0.0/installpackage.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/installpackage/1.0.0/tools/Casemismatch.exe.ignore (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/installpackage/1.0.0/tools/casemismatch.exe (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/installpackage/1.0.0/tools/chocolateyBeforeModify.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/installpackage/1.0.0/tools/chocolateyinstall.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/installpackage/1.0.0/tools/chocolateyuninstall.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/installpackage/1.0.0/tools/console.exe (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/installpackage/1.0.0/tools/graphical.exe (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/installpackage/1.0.0/tools/graphical.exe.gui (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/installpackage/1.0.0/tools/not.installed.exe (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/installpackage/1.0.0/tools/not.installed.exe.ignore (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/packagewithscript/1.0.0/packagewithscript.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/packagewithscript/1.0.0/tools/chocolateyBeforeModify.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/packagewithscript/1.0.0/tools/chocolateyinstall.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/packagewithscript/1.0.0/tools/chocolateyuninstall.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/too-long-description/1.0.0/too-long-description.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/too-long-title/1.0.0/too-long-title.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/zip-log-disable-test/tools/chocolateyinstall.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/zip-log-disable-test/tools/zip-log-disable-test.zip (100%) rename tests/{chocolatey-tests => pester-tests}/commands/testpackages/zip-log-disable-test/zip-log-disable-test.nuspec (100%) rename tests/{chocolatey-tests => pester-tests}/features/ChocolateyCache.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/features/ChocolateyFunctions.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/features/EnvironmentVariables.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/features/Hooks.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/features/Proxy.Tests.ps1 (100%) rename tests/{chocolatey-tests => pester-tests}/features/PythonSource.Tests.ps1 (100%) diff --git a/tests/chocolatey-tests/BundledApplications.Tests.ps1 b/tests/pester-tests/BundledApplications.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/BundledApplications.Tests.ps1 rename to tests/pester-tests/BundledApplications.Tests.ps1 diff --git a/tests/chocolatey-tests/TestCertificate.pfx b/tests/pester-tests/TestCertificate.pfx similarity index 100% rename from tests/chocolatey-tests/TestCertificate.pfx rename to tests/pester-tests/TestCertificate.pfx diff --git a/tests/chocolatey-tests/chocolatey.Tests.ps1 b/tests/pester-tests/chocolatey.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/chocolatey.Tests.ps1 rename to tests/pester-tests/chocolatey.Tests.ps1 diff --git a/tests/chocolatey-tests/chocolateyProfile.Tests.ps1 b/tests/pester-tests/chocolateyProfile.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/chocolateyProfile.Tests.ps1 rename to tests/pester-tests/chocolateyProfile.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-apikey.Tests.ps1 b/tests/pester-tests/commands/choco-apikey.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-apikey.Tests.ps1 rename to tests/pester-tests/commands/choco-apikey.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-config.Tests.ps1 b/tests/pester-tests/commands/choco-config.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-config.Tests.ps1 rename to tests/pester-tests/commands/choco-config.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-export.Tests.ps1 b/tests/pester-tests/commands/choco-export.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-export.Tests.ps1 rename to tests/pester-tests/commands/choco-export.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-feature.Tests.ps1 b/tests/pester-tests/commands/choco-feature.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-feature.Tests.ps1 rename to tests/pester-tests/commands/choco-feature.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-help.Tests.ps1 b/tests/pester-tests/commands/choco-help.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-help.Tests.ps1 rename to tests/pester-tests/commands/choco-help.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-info.Tests.ps1 b/tests/pester-tests/commands/choco-info.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-info.Tests.ps1 rename to tests/pester-tests/commands/choco-info.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-install.Tests.ps1 b/tests/pester-tests/commands/choco-install.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-install.Tests.ps1 rename to tests/pester-tests/commands/choco-install.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-list.Tests.ps1 b/tests/pester-tests/commands/choco-list.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-list.Tests.ps1 rename to tests/pester-tests/commands/choco-list.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-new.Tests.ps1 b/tests/pester-tests/commands/choco-new.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-new.Tests.ps1 rename to tests/pester-tests/commands/choco-new.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-outdated.Tests.ps1 b/tests/pester-tests/commands/choco-outdated.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-outdated.Tests.ps1 rename to tests/pester-tests/commands/choco-outdated.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-pack.Tests.ps1 b/tests/pester-tests/commands/choco-pack.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-pack.Tests.ps1 rename to tests/pester-tests/commands/choco-pack.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-pin.Tests.ps1 b/tests/pester-tests/commands/choco-pin.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-pin.Tests.ps1 rename to tests/pester-tests/commands/choco-pin.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-push.Tests.ps1 b/tests/pester-tests/commands/choco-push.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-push.Tests.ps1 rename to tests/pester-tests/commands/choco-push.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-removed.Tests.ps1 b/tests/pester-tests/commands/choco-removed.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-removed.Tests.ps1 rename to tests/pester-tests/commands/choco-removed.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-search.Tests.ps1 b/tests/pester-tests/commands/choco-search.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-search.Tests.ps1 rename to tests/pester-tests/commands/choco-search.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-source.Tests.ps1 b/tests/pester-tests/commands/choco-source.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-source.Tests.ps1 rename to tests/pester-tests/commands/choco-source.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-template.Tests.ps1 b/tests/pester-tests/commands/choco-template.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-template.Tests.ps1 rename to tests/pester-tests/commands/choco-template.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-uninstall.Tests.ps1 b/tests/pester-tests/commands/choco-uninstall.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-uninstall.Tests.ps1 rename to tests/pester-tests/commands/choco-uninstall.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-upgrade.Tests.ps1 b/tests/pester-tests/commands/choco-upgrade.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-upgrade.Tests.ps1 rename to tests/pester-tests/commands/choco-upgrade.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/choco-version.Tests.ps1 b/tests/pester-tests/commands/choco-version.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/choco-version.Tests.ps1 rename to tests/pester-tests/commands/choco-version.Tests.ps1 diff --git a/tests/chocolatey-tests/commands/testnuspecs/basic-dependencies/basic-dependencies.nuspec b/tests/pester-tests/commands/testnuspecs/basic-dependencies/basic-dependencies.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/basic-dependencies/basic-dependencies.nuspec rename to tests/pester-tests/commands/testnuspecs/basic-dependencies/basic-dependencies.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/basic/basic.nuspec b/tests/pester-tests/commands/testnuspecs/basic/basic.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/basic/basic.nuspec rename to tests/pester-tests/commands/testnuspecs/basic/basic.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/basic/tools/purpose.txt b/tests/pester-tests/commands/testnuspecs/basic/tools/purpose.txt similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/basic/tools/purpose.txt rename to tests/pester-tests/commands/testnuspecs/basic/tools/purpose.txt diff --git a/tests/chocolatey-tests/commands/testnuspecs/cdata/cdata.nuspec b/tests/pester-tests/commands/testnuspecs/cdata/cdata.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/cdata/cdata.nuspec rename to tests/pester-tests/commands/testnuspecs/cdata/cdata.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/description-long.nuspec b/tests/pester-tests/commands/testnuspecs/description-long.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/description-long.nuspec rename to tests/pester-tests/commands/testnuspecs/description-long.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/empty-requireLicenseAcceptance.nuspec b/tests/pester-tests/commands/testnuspecs/empty-requireLicenseAcceptance.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/empty-requireLicenseAcceptance.nuspec rename to tests/pester-tests/commands/testnuspecs/empty-requireLicenseAcceptance.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/empty.nuspec b/tests/pester-tests/commands/testnuspecs/empty.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/empty.nuspec rename to tests/pester-tests/commands/testnuspecs/empty.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/forward-slash/forward-slash.nuspec b/tests/pester-tests/commands/testnuspecs/forward-slash/forward-slash.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/forward-slash/forward-slash.nuspec rename to tests/pester-tests/commands/testnuspecs/forward-slash/forward-slash.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/forward-slash/tools/purpose.txt b/tests/pester-tests/commands/testnuspecs/forward-slash/tools/purpose.txt similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/forward-slash/tools/purpose.txt rename to tests/pester-tests/commands/testnuspecs/forward-slash/tools/purpose.txt diff --git a/tests/chocolatey-tests/commands/testnuspecs/full/full.nuspec b/tests/pester-tests/commands/testnuspecs/full/full.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/full/full.nuspec rename to tests/pester-tests/commands/testnuspecs/full/full.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/full/tools/purpose.txt b/tests/pester-tests/commands/testnuspecs/full/tools/purpose.txt similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/full/tools/purpose.txt rename to tests/pester-tests/commands/testnuspecs/full/tools/purpose.txt diff --git a/tests/chocolatey-tests/commands/testnuspecs/invalid-bugtrackerurl.nuspec b/tests/pester-tests/commands/testnuspecs/invalid-bugtrackerurl.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/invalid-bugtrackerurl.nuspec rename to tests/pester-tests/commands/testnuspecs/invalid-bugtrackerurl.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/invalid-character-and.nuspec b/tests/pester-tests/commands/testnuspecs/invalid-character-and.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/invalid-character-and.nuspec rename to tests/pester-tests/commands/testnuspecs/invalid-character-and.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/invalid-character-lesser.nuspec b/tests/pester-tests/commands/testnuspecs/invalid-character-lesser.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/invalid-character-lesser.nuspec rename to tests/pester-tests/commands/testnuspecs/invalid-character-lesser.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/invalid-docsurl.nuspec b/tests/pester-tests/commands/testnuspecs/invalid-docsurl.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/invalid-docsurl.nuspec rename to tests/pester-tests/commands/testnuspecs/invalid-docsurl.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/invalid-iconurl.nuspec b/tests/pester-tests/commands/testnuspecs/invalid-iconurl.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/invalid-iconurl.nuspec rename to tests/pester-tests/commands/testnuspecs/invalid-iconurl.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/invalid-id.nuspec b/tests/pester-tests/commands/testnuspecs/invalid-id.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/invalid-id.nuspec rename to tests/pester-tests/commands/testnuspecs/invalid-id.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/invalid-licenseUrl.nuspec b/tests/pester-tests/commands/testnuspecs/invalid-licenseUrl.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/invalid-licenseUrl.nuspec rename to tests/pester-tests/commands/testnuspecs/invalid-licenseUrl.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/invalid-mailinglisturl.nuspec b/tests/pester-tests/commands/testnuspecs/invalid-mailinglisturl.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/invalid-mailinglisturl.nuspec rename to tests/pester-tests/commands/testnuspecs/invalid-mailinglisturl.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/invalid-no-content.nuspec b/tests/pester-tests/commands/testnuspecs/invalid-no-content.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/invalid-no-content.nuspec rename to tests/pester-tests/commands/testnuspecs/invalid-no-content.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/invalid-projectsourceurl.nuspec b/tests/pester-tests/commands/testnuspecs/invalid-projectsourceurl.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/invalid-projectsourceurl.nuspec rename to tests/pester-tests/commands/testnuspecs/invalid-projectsourceurl.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/invalid-projecturl.nuspec b/tests/pester-tests/commands/testnuspecs/invalid-projecturl.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/invalid-projecturl.nuspec rename to tests/pester-tests/commands/testnuspecs/invalid-projecturl.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/invalid-requireLicenseAcceptance.nuspec b/tests/pester-tests/commands/testnuspecs/invalid-requireLicenseAcceptance.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/invalid-requireLicenseAcceptance.nuspec rename to tests/pester-tests/commands/testnuspecs/invalid-requireLicenseAcceptance.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/invalid-version.nuspec b/tests/pester-tests/commands/testnuspecs/invalid-version.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/invalid-version.nuspec rename to tests/pester-tests/commands/testnuspecs/invalid-version.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/missing.nuspec b/tests/pester-tests/commands/testnuspecs/missing.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/missing.nuspec rename to tests/pester-tests/commands/testnuspecs/missing.nuspec diff --git a/tests/chocolatey-tests/commands/testnuspecs/required.nuspec b/tests/pester-tests/commands/testnuspecs/required.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testnuspecs/required.nuspec rename to tests/pester-tests/commands/testnuspecs/required.nuspec diff --git a/tests/chocolatey-tests/commands/testpackages/.gitignore b/tests/pester-tests/commands/testpackages/.gitignore similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/.gitignore rename to tests/pester-tests/commands/testpackages/.gitignore diff --git a/tests/chocolatey-tests/commands/testpackages/chocolatey-dummy-package/1.0.0/chocolatey-dummy-package.nuspec b/tests/pester-tests/commands/testpackages/chocolatey-dummy-package/1.0.0/chocolatey-dummy-package.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/chocolatey-dummy-package/1.0.0/chocolatey-dummy-package.nuspec rename to tests/pester-tests/commands/testpackages/chocolatey-dummy-package/1.0.0/chocolatey-dummy-package.nuspec diff --git a/tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/installpackage.nuspec b/tests/pester-tests/commands/testpackages/installpackage/1.0.0/installpackage.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/installpackage.nuspec rename to tests/pester-tests/commands/testpackages/installpackage/1.0.0/installpackage.nuspec diff --git a/tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/Casemismatch.exe.ignore b/tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/Casemismatch.exe.ignore similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/Casemismatch.exe.ignore rename to tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/Casemismatch.exe.ignore diff --git a/tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/casemismatch.exe b/tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/casemismatch.exe similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/casemismatch.exe rename to tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/casemismatch.exe diff --git a/tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/chocolateyBeforeModify.ps1 b/tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/chocolateyBeforeModify.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/chocolateyBeforeModify.ps1 rename to tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/chocolateyBeforeModify.ps1 diff --git a/tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/chocolateyinstall.ps1 b/tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/chocolateyinstall.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/chocolateyinstall.ps1 rename to tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/chocolateyinstall.ps1 diff --git a/tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/chocolateyuninstall.ps1 b/tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/chocolateyuninstall.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/chocolateyuninstall.ps1 rename to tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/chocolateyuninstall.ps1 diff --git a/tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/console.exe b/tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/console.exe similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/console.exe rename to tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/console.exe diff --git a/tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/graphical.exe b/tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/graphical.exe similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/graphical.exe rename to tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/graphical.exe diff --git a/tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/graphical.exe.gui b/tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/graphical.exe.gui similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/graphical.exe.gui rename to tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/graphical.exe.gui diff --git a/tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/not.installed.exe b/tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/not.installed.exe similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/not.installed.exe rename to tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/not.installed.exe diff --git a/tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/not.installed.exe.ignore b/tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/not.installed.exe.ignore similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/installpackage/1.0.0/tools/not.installed.exe.ignore rename to tests/pester-tests/commands/testpackages/installpackage/1.0.0/tools/not.installed.exe.ignore diff --git a/tests/chocolatey-tests/commands/testpackages/packagewithscript/1.0.0/packagewithscript.nuspec b/tests/pester-tests/commands/testpackages/packagewithscript/1.0.0/packagewithscript.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/packagewithscript/1.0.0/packagewithscript.nuspec rename to tests/pester-tests/commands/testpackages/packagewithscript/1.0.0/packagewithscript.nuspec diff --git a/tests/chocolatey-tests/commands/testpackages/packagewithscript/1.0.0/tools/chocolateyBeforeModify.ps1 b/tests/pester-tests/commands/testpackages/packagewithscript/1.0.0/tools/chocolateyBeforeModify.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/packagewithscript/1.0.0/tools/chocolateyBeforeModify.ps1 rename to tests/pester-tests/commands/testpackages/packagewithscript/1.0.0/tools/chocolateyBeforeModify.ps1 diff --git a/tests/chocolatey-tests/commands/testpackages/packagewithscript/1.0.0/tools/chocolateyinstall.ps1 b/tests/pester-tests/commands/testpackages/packagewithscript/1.0.0/tools/chocolateyinstall.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/packagewithscript/1.0.0/tools/chocolateyinstall.ps1 rename to tests/pester-tests/commands/testpackages/packagewithscript/1.0.0/tools/chocolateyinstall.ps1 diff --git a/tests/chocolatey-tests/commands/testpackages/packagewithscript/1.0.0/tools/chocolateyuninstall.ps1 b/tests/pester-tests/commands/testpackages/packagewithscript/1.0.0/tools/chocolateyuninstall.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/packagewithscript/1.0.0/tools/chocolateyuninstall.ps1 rename to tests/pester-tests/commands/testpackages/packagewithscript/1.0.0/tools/chocolateyuninstall.ps1 diff --git a/tests/chocolatey-tests/commands/testpackages/too-long-description/1.0.0/too-long-description.nuspec b/tests/pester-tests/commands/testpackages/too-long-description/1.0.0/too-long-description.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/too-long-description/1.0.0/too-long-description.nuspec rename to tests/pester-tests/commands/testpackages/too-long-description/1.0.0/too-long-description.nuspec diff --git a/tests/chocolatey-tests/commands/testpackages/too-long-title/1.0.0/too-long-title.nuspec b/tests/pester-tests/commands/testpackages/too-long-title/1.0.0/too-long-title.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/too-long-title/1.0.0/too-long-title.nuspec rename to tests/pester-tests/commands/testpackages/too-long-title/1.0.0/too-long-title.nuspec diff --git a/tests/chocolatey-tests/commands/testpackages/zip-log-disable-test/tools/chocolateyinstall.ps1 b/tests/pester-tests/commands/testpackages/zip-log-disable-test/tools/chocolateyinstall.ps1 similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/zip-log-disable-test/tools/chocolateyinstall.ps1 rename to tests/pester-tests/commands/testpackages/zip-log-disable-test/tools/chocolateyinstall.ps1 diff --git a/tests/chocolatey-tests/commands/testpackages/zip-log-disable-test/tools/zip-log-disable-test.zip b/tests/pester-tests/commands/testpackages/zip-log-disable-test/tools/zip-log-disable-test.zip similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/zip-log-disable-test/tools/zip-log-disable-test.zip rename to tests/pester-tests/commands/testpackages/zip-log-disable-test/tools/zip-log-disable-test.zip diff --git a/tests/chocolatey-tests/commands/testpackages/zip-log-disable-test/zip-log-disable-test.nuspec b/tests/pester-tests/commands/testpackages/zip-log-disable-test/zip-log-disable-test.nuspec similarity index 100% rename from tests/chocolatey-tests/commands/testpackages/zip-log-disable-test/zip-log-disable-test.nuspec rename to tests/pester-tests/commands/testpackages/zip-log-disable-test/zip-log-disable-test.nuspec diff --git a/tests/chocolatey-tests/features/ChocolateyCache.Tests.ps1 b/tests/pester-tests/features/ChocolateyCache.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/features/ChocolateyCache.Tests.ps1 rename to tests/pester-tests/features/ChocolateyCache.Tests.ps1 diff --git a/tests/chocolatey-tests/features/ChocolateyFunctions.Tests.ps1 b/tests/pester-tests/features/ChocolateyFunctions.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/features/ChocolateyFunctions.Tests.ps1 rename to tests/pester-tests/features/ChocolateyFunctions.Tests.ps1 diff --git a/tests/chocolatey-tests/features/EnvironmentVariables.Tests.ps1 b/tests/pester-tests/features/EnvironmentVariables.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/features/EnvironmentVariables.Tests.ps1 rename to tests/pester-tests/features/EnvironmentVariables.Tests.ps1 diff --git a/tests/chocolatey-tests/features/Hooks.Tests.ps1 b/tests/pester-tests/features/Hooks.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/features/Hooks.Tests.ps1 rename to tests/pester-tests/features/Hooks.Tests.ps1 diff --git a/tests/chocolatey-tests/features/Proxy.Tests.ps1 b/tests/pester-tests/features/Proxy.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/features/Proxy.Tests.ps1 rename to tests/pester-tests/features/Proxy.Tests.ps1 diff --git a/tests/chocolatey-tests/features/PythonSource.Tests.ps1 b/tests/pester-tests/features/PythonSource.Tests.ps1 similarity index 100% rename from tests/chocolatey-tests/features/PythonSource.Tests.ps1 rename to tests/pester-tests/features/PythonSource.Tests.ps1 From f6ac3e9cd28f83f54ee8daf1e0015ab3164ea98f Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Wed, 25 Oct 2023 10:37:55 -0700 Subject: [PATCH 02/37] (maint) Update Invoke-Tests.ps1 Update invoke script for new Pester tests location. --- Invoke-Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Invoke-Tests.ps1 b/Invoke-Tests.ps1 index 91ef6510aa..4dbbbec82d 100644 --- a/Invoke-Tests.ps1 +++ b/Invoke-Tests.ps1 @@ -97,7 +97,7 @@ try { $PesterConfiguration = [PesterConfiguration]@{ Run = @{ PassThru = $true - Path = "$PSScriptRoot/tests/chocolatey-tests" + Path = "$PSScriptRoot/tests/pester-tests" } TestResult = @{ Enabled = $true From fadd3b2e631e5d96221850ad3d06f064161ba98b Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Mon, 18 Dec 2023 12:40:07 -0800 Subject: [PATCH 03/37] (#2712) Normalize ExitCode pester tests We haven't been consistent when checking the exit code of the Chocolatey command run. This commit updates all instances where we're testing ExitCode on the output object to also include the String propery if the ExitCode doesn't match. This allows us to better deduce issues as we have the Chocolatey output as well. --- tests/pester-tests/chocolatey.Tests.ps1 | 6 ++-- .../commands/choco-apikey.Tests.ps1 | 26 ++++++++--------- .../commands/choco-config.Tests.ps1 | 18 ++++++------ .../commands/choco-export.Tests.ps1 | 20 ++++++------- .../commands/choco-feature.Tests.ps1 | 12 ++++---- .../commands/choco-help.Tests.ps1 | 4 +-- .../commands/choco-list.Tests.ps1 | 12 ++++---- .../pester-tests/commands/choco-new.Tests.ps1 | 8 +++--- .../commands/choco-pack.Tests.ps1 | 28 +++++++++---------- .../pester-tests/commands/choco-pin.Tests.ps1 | 18 ++++++------ .../commands/choco-removed.Tests.ps1 | 10 +++---- .../commands/choco-search.Tests.ps1 | 24 ++++++++-------- .../commands/choco-source.Tests.ps1 | 26 ++++++++--------- .../commands/choco-template.Tests.ps1 | 16 +++++------ .../commands/choco-uninstall.Tests.ps1 | 2 +- .../commands/choco-upgrade.Tests.ps1 | 4 +-- .../commands/choco-version.Tests.ps1 | 4 +-- 17 files changed, 119 insertions(+), 119 deletions(-) diff --git a/tests/pester-tests/chocolatey.Tests.ps1 b/tests/pester-tests/chocolatey.Tests.ps1 index ee1a485d66..f35721189a 100644 --- a/tests/pester-tests/chocolatey.Tests.ps1 +++ b/tests/pester-tests/chocolatey.Tests.ps1 @@ -83,7 +83,7 @@ Describe "Ensuring Chocolatey is correctly installed" -Tag Environment, Chocolat It "Outputs the version when run with --version" { $Output = Invoke-Choco --version $script:CurrentVersion = $Output.String - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String $LastExitCode | Should -Be 0 ($Output.String -split '-' | Select-Object -First 1) -as [version] | Should -BeTrue } @@ -345,7 +345,7 @@ exit $error.count } It 'should exit Success (0)' { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It 'should shim <_> on upgrade' -ForEach $RemovedShims { @@ -369,7 +369,7 @@ exit $error.count } It 'Exits with Success (0)' { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It 'Should remove the invalid configuration file' { diff --git a/tests/pester-tests/commands/choco-apikey.Tests.ps1 b/tests/pester-tests/commands/choco-apikey.Tests.ps1 index c3e74a2219..5ed9daf81f 100644 --- a/tests/pester-tests/commands/choco-apikey.Tests.ps1 +++ b/tests/pester-tests/commands/choco-apikey.Tests.ps1 @@ -27,7 +27,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Only displays chocolatey name with version" { @@ -42,7 +42,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Only displays chocolatey name with version" { @@ -57,7 +57,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Only displays chocolatey name with version" { @@ -71,7 +71,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Only displays chocolatey name with version" { @@ -104,7 +104,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -148,7 +148,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -195,7 +195,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -243,7 +243,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -275,7 +275,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -299,7 +299,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -317,7 +317,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand { } It "Exits with Failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Displays chocolatey name with version" { @@ -337,7 +337,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -358,7 +358,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { diff --git a/tests/pester-tests/commands/choco-config.Tests.ps1 b/tests/pester-tests/commands/choco-config.Tests.ps1 index 59918886ea..92868b84a3 100644 --- a/tests/pester-tests/commands/choco-config.Tests.ps1 +++ b/tests/pester-tests/commands/choco-config.Tests.ps1 @@ -62,7 +62,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -104,7 +104,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -122,7 +122,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -140,7 +140,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand { } It "Exits with failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Outputs an error indicating that there's no config by that name" { @@ -157,7 +157,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -184,7 +184,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -211,7 +211,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -241,7 +241,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -268,7 +268,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { diff --git a/tests/pester-tests/commands/choco-export.Tests.ps1 b/tests/pester-tests/commands/choco-export.Tests.ps1 index 97b7fa8a8b..7f78f1c7f6 100644 --- a/tests/pester-tests/commands/choco-export.Tests.ps1 +++ b/tests/pester-tests/commands/choco-export.Tests.ps1 @@ -76,7 +76,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays description of command" { @@ -133,7 +133,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand { } It "Exits with success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } # NOTE: There is no output other than the header, and possibly the unofficial statement @@ -184,7 +184,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand { } It "Exits with success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } # NOTE: There is no output other than the header, and possibly the unofficial statement @@ -226,7 +226,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand { } It "Exits with success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } # NOTE: There is no output other than the header, and possibly the unofficial statement @@ -277,7 +277,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand { } It "Exits with success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } # NOTE: There is no output other than the header, and possibly the unofficial statement @@ -319,7 +319,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand { } It "Exits with success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } # NOTE: There is no output other than the header, and possibly the unofficial statement @@ -387,7 +387,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand { } It "Exits with success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } # NOTE: There is no output other than the header, and possibly the unofficial statement @@ -415,7 +415,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand { } It "Exits with Failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Reports unable to export packages" { @@ -439,7 +439,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand { } It "Exits with Failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Reports unable to export packages" { @@ -459,7 +459,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand { } It "Exits with Failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Displays help page" { diff --git a/tests/pester-tests/commands/choco-feature.Tests.ps1 b/tests/pester-tests/commands/choco-feature.Tests.ps1 index 8f56cd1439..21322d8b78 100644 --- a/tests/pester-tests/commands/choco-feature.Tests.ps1 +++ b/tests/pester-tests/commands/choco-feature.Tests.ps1 @@ -37,7 +37,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, FeatureCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Lists available features" { @@ -124,7 +124,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, FeatureCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Outputs a message indicating that it disabled the feature" { @@ -148,7 +148,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, FeatureCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Outputs a message indicating that it enabled the feature" { @@ -172,7 +172,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, FeatureCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Outputs a message indicating that it disabled the feature" { @@ -192,7 +192,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, FeatureCommand { } It "Exits with Failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Outputs a message indicating it didn't find the feature in question" { @@ -209,7 +209,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, FeatureCommand { } It "Exits with Failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Outputs a message indicating it didn't find the feature in question" { diff --git a/tests/pester-tests/commands/choco-help.Tests.ps1 b/tests/pester-tests/commands/choco-help.Tests.ps1 index 68f854ec2f..fd147ff548 100644 --- a/tests/pester-tests/commands/choco-help.Tests.ps1 +++ b/tests/pester-tests/commands/choco-help.Tests.ps1 @@ -43,7 +43,7 @@ Describe "choco help sections with option <_>" -ForEach $HelpOptions -Tag Chocol } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Outputs the Top-Level Help" { @@ -68,7 +68,7 @@ Describe "choco help sections with option <_>" -ForEach $HelpOptions -Tag Chocol } It "'choco <_> $helpArgument' exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Outputs help for <_>" { diff --git a/tests/pester-tests/commands/choco-list.Tests.ps1 b/tests/pester-tests/commands/choco-list.Tests.ps1 index d30e8465f4..32d7d3e8f7 100644 --- a/tests/pester-tests/commands/choco-list.Tests.ps1 +++ b/tests/pester-tests/commands/choco-list.Tests.ps1 @@ -21,7 +21,7 @@ Describe "choco list" -Tag Chocolatey, ListCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Should contain packages and version with a space between them" { @@ -43,7 +43,7 @@ Describe "choco list" -Tag Chocolatey, ListCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Should not contain packages and version with a space between them" { @@ -65,7 +65,7 @@ Describe "choco list" -Tag Chocolatey, ListCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Should contain package name(s)" { @@ -87,7 +87,7 @@ Describe "choco list" -Tag Chocolatey, ListCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Should contain package isexactversiondependency" { @@ -105,7 +105,7 @@ Describe "choco list" -Tag Chocolatey, ListCommand { } It "Exits with Failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Should output expected error message" { @@ -119,7 +119,7 @@ Describe "choco list" -Tag Chocolatey, ListCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Should not output the error message" { diff --git a/tests/pester-tests/commands/choco-new.Tests.ps1 b/tests/pester-tests/commands/choco-new.Tests.ps1 index 9f3d0018f1..31e74d3776 100644 --- a/tests/pester-tests/commands/choco-new.Tests.ps1 +++ b/tests/pester-tests/commands/choco-new.Tests.ps1 @@ -35,7 +35,7 @@ Describe "choco new" -Tag Chocolatey, NewCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -83,7 +83,7 @@ Describe "choco new" -Tag Chocolatey, NewCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -117,7 +117,7 @@ Describe "choco new" -Tag Chocolatey, NewCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -151,7 +151,7 @@ Describe "choco new" -Tag Chocolatey, NewCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Creates the empty folders expected (<_>)" -ForEach $EmptyFolders { diff --git a/tests/pester-tests/commands/choco-pack.Tests.ps1 b/tests/pester-tests/commands/choco-pack.Tests.ps1 index 7ddc606167..d863708fb7 100644 --- a/tests/pester-tests/commands/choco-pack.Tests.ps1 +++ b/tests/pester-tests/commands/choco-pack.Tests.ps1 @@ -61,7 +61,7 @@ Describe "choco pack" -Tag Chocolatey, PackCommand { } It "'choco pack' exits with Failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Outputs Error Message" { @@ -85,7 +85,7 @@ Describe "choco pack" -Tag Chocolatey, PackCommand { } It "'choco pack' exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays Chocolatey name with version" { @@ -115,7 +115,7 @@ Describe "choco pack" -Tag Chocolatey, PackCommand { } It "'choco pack' exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays Chocolatey name with version" { @@ -146,7 +146,7 @@ Describe "choco pack" -Tag Chocolatey, PackCommand { } It "'choco pack' exits with Failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Displays Chocolatey name with version" { @@ -181,7 +181,7 @@ Describe "choco pack" -Tag Chocolatey, PackCommand { } It "'choco pack' exits with Failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Displays Chocolatey name with version" { @@ -216,7 +216,7 @@ Describe "choco pack" -Tag Chocolatey, PackCommand { } It "'choco pack' exits with Failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Displays serialize error" { @@ -248,7 +248,7 @@ Describe "choco pack" -Tag Chocolatey, PackCommand { } It "'choco pack' exits with Failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Displays Chocolatey name with version" { @@ -283,7 +283,7 @@ Describe "choco pack" -Tag Chocolatey, PackCommand { } It "'choco pack' exits with Failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Displays Chocolatey name with version" { @@ -323,7 +323,7 @@ Describe "choco pack" -Tag Chocolatey, PackCommand { } It "'choco pack' exits with Failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Displays Chocolatey name with version" { @@ -353,7 +353,7 @@ Describe "choco pack" -Tag Chocolatey, PackCommand { } It "'choco pack' exits with Failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Displays Chocolatey name with version" { @@ -383,7 +383,7 @@ Describe "choco pack" -Tag Chocolatey, PackCommand { } It "'choco pack' exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays Chocolatey name with version" { @@ -423,7 +423,7 @@ Describe "choco pack" -Tag Chocolatey, PackCommand { } It "'choco pack' exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays Chocolatey name with version" { @@ -460,7 +460,7 @@ Describe "choco pack" -Tag Chocolatey, PackCommand { } It "'choco pack' exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays Chocolatey name with version" { @@ -565,7 +565,7 @@ Describe "choco pack" -Tag Chocolatey, PackCommand { } It 'Fails to pack and exits with an error (1)' { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It 'Shows an error about the unsupported nuspec metadata element "<_>"' -TestCases $testCases { diff --git a/tests/pester-tests/commands/choco-pin.Tests.ps1 b/tests/pester-tests/commands/choco-pin.Tests.ps1 index 8801b56474..465b434cf7 100644 --- a/tests/pester-tests/commands/choco-pin.Tests.ps1 +++ b/tests/pester-tests/commands/choco-pin.Tests.ps1 @@ -30,7 +30,7 @@ Describe "choco pin" -Tag Chocolatey, PinCommand { } It "Exits with ExitCode 0" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Has no Pins listed" { @@ -48,7 +48,7 @@ Describe "choco pin" -Tag Chocolatey, PinCommand { } It "Exits with ExitCode 0" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Lists the new Pin" { @@ -67,7 +67,7 @@ Describe "choco pin" -Tag Chocolatey, PinCommand { } It "Exits with ExitCode 0" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Lists the Pins" { @@ -85,7 +85,7 @@ Describe "choco pin" -Tag Chocolatey, PinCommand { } It "Exits with ExitCode 0" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Sets the Pin" { @@ -105,7 +105,7 @@ Describe "choco pin" -Tag Chocolatey, PinCommand { } It "Exits with ExitCode 0" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Changes Nothing" { @@ -123,7 +123,7 @@ Describe "choco pin" -Tag Chocolatey, PinCommand { } It "Exits with ExitCode 1" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Outputs a message indicating the failure" { @@ -146,7 +146,7 @@ Describe "choco pin" -Tag Chocolatey, PinCommand { } It "Exits with ExitCode 0" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Removed the Pin" { @@ -163,7 +163,7 @@ Describe "choco pin" -Tag Chocolatey, PinCommand { } It "Exits with ExitCode 0" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Changes Nothing" { @@ -179,7 +179,7 @@ Describe "choco pin" -Tag Chocolatey, PinCommand { } It "Exits with ExitCode 1" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Outputs a message indicating the failure" { diff --git a/tests/pester-tests/commands/choco-removed.Tests.ps1 b/tests/pester-tests/commands/choco-removed.Tests.ps1 index e74c9e3304..bfa350b92d 100644 --- a/tests/pester-tests/commands/choco-removed.Tests.ps1 +++ b/tests/pester-tests/commands/choco-removed.Tests.ps1 @@ -37,7 +37,7 @@ exit $command.Count } It 'Exits with Success (0)' { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It 'Reports the correct command name' { @@ -68,7 +68,7 @@ exit $command.Count } It 'Exits with Failure (1)' { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It 'Reports missing API key' { @@ -85,7 +85,7 @@ exit $command.Count } It 'Exits with Failure (1)' { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Reports that the command doesn't exist" { @@ -113,7 +113,7 @@ exit $command.Count } It 'Exits with Failure (1)' { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Reports that the path for the source could not be resolved" { @@ -127,7 +127,7 @@ exit $command.Count } It 'Exits with Success (0)' { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Reports that the command doesn't exist" { diff --git a/tests/pester-tests/commands/choco-search.Tests.ps1 b/tests/pester-tests/commands/choco-search.Tests.ps1 index 442fdd3b8a..15b4fe5801 100644 --- a/tests/pester-tests/commands/choco-search.Tests.ps1 +++ b/tests/pester-tests/commands/choco-search.Tests.ps1 @@ -43,7 +43,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SearchCommand, FindComma } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Lists available packages once" { @@ -70,7 +70,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SearchCommand, FindComma } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Contains packages and versions with a space between them" { @@ -93,7 +93,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SearchCommand, FindComma } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Shows each instance of an available package" { @@ -119,7 +119,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SearchCommand, FindComma } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Shows each instance of an available package" { @@ -149,7 +149,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SearchCommand, FindComma } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Shows version <_> of the package" -ForEach @("1.1.0"; "1.0.0") { @@ -164,7 +164,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SearchCommand, FindComma } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Should contain packages and version with a space between them" { @@ -201,7 +201,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SearchCommand, FindComma } It "Exits with Failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Outputs an appropriate message to indicate the failure to search no sources, and nothing else" { @@ -215,7 +215,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SearchCommand, FindComma } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Should contain packages and version with a space between them" { @@ -265,7 +265,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SearchCommand, FindComma } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays the package <_>" -ForEach @("mvcmusicstore-db 1.2.0"; "mvcmusicstore-web 1.2.0") { @@ -288,7 +288,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SearchCommand, FindComma } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays the package <_>" -ForEach @("mvcmusicstore-db 1.2.0"; "mvcmusicstore-web 1.2.0") { @@ -309,7 +309,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SearchCommand, FindComma } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Should list package isexactversiondependency v<_>" -ForEach @("1.0.1"; "1.0.0"; "2.0.0"; "1.1.0") { @@ -329,7 +329,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SearchCommand, FindComma } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Should list package isexactversiondependency v<_>" -ForEach @("1.0.1"; "1.0.0"; "2.0.0"; "1.1.0"; "1.0.0-beta") { diff --git a/tests/pester-tests/commands/choco-source.Tests.ps1 b/tests/pester-tests/commands/choco-source.Tests.ps1 index 8220951ae9..701550edad 100644 --- a/tests/pester-tests/commands/choco-source.Tests.ps1 +++ b/tests/pester-tests/commands/choco-source.Tests.ps1 @@ -42,7 +42,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -76,7 +76,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -120,7 +120,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -167,7 +167,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -206,7 +206,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -232,7 +232,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -263,7 +263,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Displays chocolatey name with version" { @@ -287,7 +287,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -311,7 +311,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -335,7 +335,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -366,7 +366,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -394,7 +394,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { @@ -415,7 +415,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays chocolatey name with version" { diff --git a/tests/pester-tests/commands/choco-template.Tests.ps1 b/tests/pester-tests/commands/choco-template.Tests.ps1 index c5f65ad0d0..55ba42cb7c 100644 --- a/tests/pester-tests/commands/choco-template.Tests.ps1 +++ b/tests/pester-tests/commands/choco-template.Tests.ps1 @@ -28,7 +28,7 @@ Describe "choco <_>" -ForEach @( } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays the templates expected" { @@ -51,7 +51,7 @@ Describe "choco <_>" -ForEach @( } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays the templates expected" { @@ -74,7 +74,7 @@ Describe "choco <_>" -ForEach @( } It "Exits with Failure (1)" { - $Output.ExitCode | Should -Be 1 + $Output.ExitCode | Should -Be 1 -Because $Output.String } It "Displays error with correct format" { @@ -92,7 +92,7 @@ Describe "choco <_>" -ForEach @( } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays template information" { @@ -139,7 +139,7 @@ Describe "choco <_>" -ForEach @( } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays template name and version" { @@ -159,7 +159,7 @@ Describe "choco <_>" -ForEach @( } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays the templates marking the default as expected" { @@ -184,7 +184,7 @@ Describe "choco <_>" -ForEach @( } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays the templates marking the default as expected" { @@ -207,7 +207,7 @@ Describe "choco <_>" -ForEach @( } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Displays template information" -ForEach @( diff --git a/tests/pester-tests/commands/choco-uninstall.Tests.ps1 b/tests/pester-tests/commands/choco-uninstall.Tests.ps1 index 220b68ea2c..9b58cb0335 100644 --- a/tests/pester-tests/commands/choco-uninstall.Tests.ps1 +++ b/tests/pester-tests/commands/choco-uninstall.Tests.ps1 @@ -407,7 +407,7 @@ Describe "choco uninstall" -Tag Chocolatey, UninstallCommand { } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Uninstall package successfully" { diff --git a/tests/pester-tests/commands/choco-upgrade.Tests.ps1 b/tests/pester-tests/commands/choco-upgrade.Tests.ps1 index ac9ef8fdcc..befc8dfc84 100644 --- a/tests/pester-tests/commands/choco-upgrade.Tests.ps1 +++ b/tests/pester-tests/commands/choco-upgrade.Tests.ps1 @@ -491,7 +491,7 @@ To upgrade a local, or remote file, you may use: # This was broken in v1.3.1 It "Exits with Success (0)" -Tag Broken { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Outputs a message showing that installation was successful" { @@ -513,7 +513,7 @@ To upgrade a local, or remote file, you may use: } It "Exits with Success (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Outputs line with package name version and old version" { diff --git a/tests/pester-tests/commands/choco-version.Tests.ps1 b/tests/pester-tests/commands/choco-version.Tests.ps1 index 4568656dae..c7d8e3f795 100644 --- a/tests/pester-tests/commands/choco-version.Tests.ps1 +++ b/tests/pester-tests/commands/choco-version.Tests.ps1 @@ -17,7 +17,7 @@ Describe "choco version" -Tag Chocolatey, VersionCommand -Skip:(Test-ChocolateyV } It "Exits successfully (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Reports that the command is deprecated" { @@ -36,7 +36,7 @@ Describe "choco version" -Tag Chocolatey, VersionCommand -Skip:(Test-ChocolateyV } It "Exits successfully (0)" { - $Output.ExitCode | Should -Be 0 + $Output.ExitCode | Should -Be 0 -Because $Output.String } It "Outputs Help for Version" { From d940f0f19a0f6d129be88b15982670e07b778676 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Wed, 20 Dec 2023 15:01:04 +0000 Subject: [PATCH 04/37] (maint) Update GRM configuration This commit makes a very small change to GRM configuration, to add a space between the 2 emojis. This doesn't cause problem for GitHub, but it does in GitLab, so to keep things the same, let's add the space. --- gitreleasemanager.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitreleasemanager.yaml b/gitreleasemanager.yaml index 67025842b0..dfdc8743d3 100644 --- a/gitreleasemanager.yaml +++ b/gitreleasemanager.yaml @@ -35,4 +35,4 @@ close: - [GitHub Release](https://github.com/{owner}/{repository}/releases/tag/{milestone}) - [Chocolatey Package](https://chocolatey.org/packages/chocolatey/{milestone}) - Your **[GitReleaseManager](https://github.com/GitTools/GitReleaseManager)** bot :package::rocket: + Your **[GitReleaseManager](https://github.com/GitTools/GitReleaseManager)** bot :package: :rocket: From 256e235dca9ba87c232c98e64abfb1c12aff2e01 Mon Sep 17 00:00:00 2001 From: choco-sync Date: Wed, 6 Sep 2023 17:32:58 +0000 Subject: [PATCH 05/37] (maint) synced local '.templates/' with remote '.github/GitReleaseManager/.templates/' --- .templates/default/issue-note.sbn | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.templates/default/issue-note.sbn b/.templates/default/issue-note.sbn index 01ae15c08e..10c10a97d3 100644 --- a/.templates/default/issue-note.sbn +++ b/.templates/default/issue-note.sbn @@ -1 +1,6 @@ -- {{ issue.title }} - see [#{{ issue.number }}]({{ issue.html_url }}). +{{ + if issue_label == "Bug" || issue_label == "Bug Fix" || issue_label == "Bug Fixes" +}}- Fix - {{ issue.title }} - see [#{{ issue.number }}]({{ issue.html_url }}). +{{ else +}}- {{ issue.title }} - see [#{{ issue.number }}]({{ issue.html_url }}). +{{ end -}} From 3c938601f1bee62b3639e6840ede2db354ebd234 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Sun, 26 May 2024 23:24:49 -0700 Subject: [PATCH 06/37] (doc) Add creation of doc for choco rule command With the release of Chocolatey CLI v2.3.0 there is a new command, choco rule, which is responsible for listing out the validation rules which are currently in play. This commit adds the creation of the docs for this new command via the GenerateDocs.ps1 file. --- GenerateDocs.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/GenerateDocs.ps1 b/GenerateDocs.ps1 index 36b7197d9a..8bde26b1cc 100644 --- a/GenerateDocs.ps1 +++ b/GenerateDocs.ps1 @@ -25,6 +25,9 @@ $psModuleLocation = [System.IO.Path]::GetFullPath("$thisDirectory\src\chocolatey $docsFolder = [System.IO.Path]::GetFullPath("$thisDirectory\docs\generated") $mergedDirectory = [System.IO.Path]::GetFullPath("$thisDirectory\code_drop\temp\_PublishedApps\choco_merged") $chocoExe = "$mergedDirectory\choco.exe" + +Write-Host "Running choco.exe from $chocoExe" + $lineFeed = "`r`n" $sourceLocation = 'https://github.com/chocolatey/choco/blob/master/' $sourceCommands = $sourceLocation + 'src/chocolatey/infrastructure.app/commands' @@ -599,6 +602,7 @@ The following are experimental or use not recommended: Generate-CommandReference 'Optimize' '90' Generate-CommandReference 'Outdated' '100' Generate-CommandReference 'Pin' '110' + Generate-CommandReference 'Rule' '115' Generate-CommandReference 'Search' '120' Generate-CommandReference 'SetApiKey' '130' Generate-CommandReference 'Source' '140' From d56db96f1dc350a964f6d421a78b5a6e23053c02 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Mon, 27 May 2024 01:33:18 -0700 Subject: [PATCH 07/37] (#310) Check for presence of Location before usage During testing, it was found that the Location property of the Assembly was an entry string, therefore the cmdlets weren't being loaded. This commit attempts to address this by first checking the Location property, and if it is there, use it. Otherwise, fall back to the previous direct Import-Module against the $licensedAssembly. Will schedule a call with Rain to discuss this further once they are back from holiday. --- src/chocolatey.resources/helpers/chocolateyInstaller.psm1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 b/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 index 5ccb1ce13c..54f7aa5636 100644 --- a/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 +++ b/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 @@ -102,7 +102,11 @@ if (Test-Path $extensionsPath) { if ($licensedAssembly) { # Import-Module -Assembly doesn't work if the parent module is reimported, so force the import by path. - Import-Module $licensedAssembly.Location -Force + if ($licensedAssembly.Location) { + Import-Module $licensedAssembly.Location -Force + } else { + Import-Module $licensedAssembly + } } else { # Fallback: load the extension DLL from the path directly. From 99e53662d56a0e2ba184ed9808e12c3b5c8afdc2 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Mon, 27 May 2024 01:54:26 -0700 Subject: [PATCH 08/37] (maint) Update Authenticode Signature In the previous commit, the PowerShell file was updated, and a new signature is required. --- .../helpers/chocolateyInstaller.psm1 | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 b/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 index 54f7aa5636..dfa78d18c6 100644 --- a/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 +++ b/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 @@ -180,8 +180,8 @@ Export-ModuleMember -Function * -Alias * -Cmdlet * # SIG # Begin signature block # MIInKwYJKoZIhvcNAQcCoIInHDCCJxgCAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG -# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCCwc5bNHW/kpfcZ -# 7+n0pl1aI7nawLR48Dvt/t2uNlf8MqCCIK4wggWNMIIEdaADAgECAhAOmxiO+dAt +# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBdE9z66tk0Iy2q +# ReXBHFIMtqEDnptfyMNaqW2C2KXeYKCCIK4wggWNMIIEdaADAgECAhAOmxiO+dAt # 5+/bUOIIQBhaMA0GCSqGSIb3DQEBDAUAMGUxCzAJBgNVBAYTAlVTMRUwEwYDVQQK # EwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xJDAiBgNV # BAMTG0RpZ2lDZXJ0IEFzc3VyZWQgSUQgUm9vdCBDQTAeFw0yMjA4MDEwMDAwMDBa @@ -361,30 +361,30 @@ Export-ModuleMember -Function * -Alias * -Cmdlet * # IFNIQTM4NCAyMDIxIENBMQIQBNI793flHTneCMtwLiiYFTANBglghkgBZQMEAgEF # AKCBhDAYBgorBgE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nfIN+YRXOkC8a07LmCn7gkgZtS +# 4mx0xSSqcWzhI2dWybHpM9tad3e0Cn5nusLdC0ShZ9asW3/YLPYFbVI90g8uySU3 +# SsqafLwUMz9GDcy0GXenVploxDglVr1m6V8XrjyZl6Ljo3XXWMnfDkEfOFepRi0= # SIG # End signature block From 7bd79e444a65d5b07f382997a1ad4d2b96f68f28 Mon Sep 17 00:00:00 2001 From: AdmiringWorm Date: Mon, 27 May 2024 10:50:38 +0200 Subject: [PATCH 09/37] (#3433) Add overload for FindPackages method It was found later when including Chocolatey Licensed Extension that it would fail to load due to the change to the base source cache context. As such this commit updates the public API in this case to add the old method as a deprecated overload. --- .../infrastructure.app/nuget/NugetList.cs | 24 ++++++++++++++++++- .../services/NugetService.cs | 6 ++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/chocolatey/infrastructure.app/nuget/NugetList.cs b/src/chocolatey/infrastructure.app/nuget/NugetList.cs index 0111f65015..6048a023fa 100644 --- a/src/chocolatey/infrastructure.app/nuget/NugetList.cs +++ b/src/chocolatey/infrastructure.app/nuget/NugetList.cs @@ -248,7 +248,7 @@ private async static Task> SearchPackagesAsyn } else { - var exactPackage = FindPackage(searchTermLower, configuration, nugetLogger, cacheContext, packageRepositoryResources, version); + var exactPackage = FindPackage(searchTermLower, configuration, nugetLogger, (SourceCacheContext)cacheContext, packageRepositoryResources, version); if (exactPackage == null) { @@ -342,6 +342,28 @@ public static ISet FindAllPackageVersions(string package return metadataList; } + /// + /// Searches for packages that are available based on name and other options + /// + /// Name of package to search for + /// Chocolatey configuration used to help supply the search parameters + /// The nuget logger + /// The resources that should be queried + /// Version to search for + /// Settings for caching of results from sources + /// One result or nothing + [Obsolete("Use the overload that uses the base source cache context instead.")] + public static IPackageSearchMetadata FindPackage( + string packageName, + ChocolateyConfiguration config, + ILogger nugetLogger, + ChocolateySourceCacheContext cacheContext, + IEnumerable resources, + NuGetVersion version) + { + return FindPackage(packageName, config, nugetLogger, (SourceCacheContext)cacheContext, resources, version); + } + /// /// Searches for packages that are available based on name and other options /// diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index e91910412c..f742d93dc2 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -628,7 +628,7 @@ public virtual ConcurrentDictionary Install(ChocolateyCon latestPackageVersion = version; } - var availablePackage = NugetList.FindPackage(packageName, config, _nugetLogger, sourceCacheContext, remoteEndpoints, latestPackageVersion); + var availablePackage = NugetList.FindPackage(packageName, config, _nugetLogger, (SourceCacheContext)sourceCacheContext, remoteEndpoints, latestPackageVersion); if (availablePackage == null) { @@ -1149,7 +1149,7 @@ public virtual ConcurrentDictionary Upgrade(ChocolateyCon // this is a prerelease - opt in for newer prereleases. config.Prerelease = true; } - var availablePackage = NugetList.FindPackage(packageName, config, _nugetLogger, sourceCacheContext, remoteEndpoints, version); + var availablePackage = NugetList.FindPackage(packageName, config, _nugetLogger, (SourceCacheContext)sourceCacheContext, remoteEndpoints, version); config.Prerelease = originalPrerelease; @@ -1334,7 +1334,7 @@ public virtual ConcurrentDictionary Upgrade(ChocolateyCon { if (version != null) { - var requestedPackageDependency = NugetList.FindPackage(parentPackage.Id, config, _nugetLogger, sourceCacheContext, remoteEndpoints, version); + var requestedPackageDependency = NugetList.FindPackage(parentPackage.Id, config, _nugetLogger, (SourceCacheContext)sourceCacheContext, remoteEndpoints, version); if (requestedPackageDependency != null) { From 576527b2d164fa5cfcdf45d95a054dc02a30d2aa Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Mon, 27 May 2024 03:28:36 -0700 Subject: [PATCH 10/37] (#310) Ensure correct loading of profile During testing, it was found that the Chocolatey Profile was not being correctly loaded, with neither Update-SessionEnvironment nor refreshenv working as expected. This commit changes the profile loading to explicitly set the alas for refreshenv, and also to load Update-SessionEnvironment as a Cmdlet, rather than a Funcation. This is needed since it is now written in C# rather than PowerShell. --- src/chocolatey.resources/helpers/chocolateyProfile.psm1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/chocolatey.resources/helpers/chocolateyProfile.psm1 b/src/chocolatey.resources/helpers/chocolateyProfile.psm1 index a9968117d4..0e30982acf 100644 --- a/src/chocolatey.resources/helpers/chocolateyProfile.psm1 +++ b/src/chocolatey.resources/helpers/chocolateyProfile.psm1 @@ -25,7 +25,9 @@ Import-Module "$thisDirectory\Chocolatey.PowerShell.dll" -Cmdlet "Get-Environmen . $thisDirectory\functions\Write-FunctionCallLogMessage.ps1 . $thisDirectory\ChocolateyTabExpansion.ps1 -Export-ModuleMember -Alias refreshenv -Function 'Update-SessionEnvironment', 'TabExpansion' +Set-Alias refreshenv Update-SessionEnvironment + +Export-ModuleMember -Alias refreshenv -Cmdlet 'Update-SessionEnvironment' -Function 'TabExpansion' # SIG # Begin signature block # MIInKwYJKoZIhvcNAQcCoIInHDCCJxgCAQExDzANBglghkgBZQMEAgEFADB5Bgor From 5cb45e463f729c0c5230ce1b62febe99d6414b0c Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Mon, 27 May 2024 03:47:50 -0700 Subject: [PATCH 11/37] (maint) Update Authenticode Signature In the previous commit, the PowerShell file was updated, and a new signature is required. --- .../helpers/chocolateyProfile.psm1 | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/chocolatey.resources/helpers/chocolateyProfile.psm1 b/src/chocolatey.resources/helpers/chocolateyProfile.psm1 index 0e30982acf..aeed368810 100644 --- a/src/chocolatey.resources/helpers/chocolateyProfile.psm1 +++ b/src/chocolatey.resources/helpers/chocolateyProfile.psm1 @@ -32,8 +32,8 @@ Export-ModuleMember -Alias refreshenv -Cmdlet 'Update-SessionEnvironment' -Funct # SIG # Begin signature block # MIInKwYJKoZIhvcNAQcCoIInHDCCJxgCAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG -# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCDVITi5ehNxewn2 -# brDS2sE656mB6k07eSxGAfbiBaY0PKCCIK4wggWNMIIEdaADAgECAhAOmxiO+dAt +# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCC7eXGNrikxA4wn +# J9PdpPo/8IvwVFuZPVPleXxyzmxMLaCCIK4wggWNMIIEdaADAgECAhAOmxiO+dAt # 5+/bUOIIQBhaMA0GCSqGSIb3DQEBDAUAMGUxCzAJBgNVBAYTAlVTMRUwEwYDVQQK # EwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xJDAiBgNV # BAMTG0RpZ2lDZXJ0IEFzc3VyZWQgSUQgUm9vdCBDQTAeFw0yMjA4MDEwMDAwMDBa @@ -213,30 +213,30 @@ Export-ModuleMember -Alias refreshenv -Cmdlet 'Update-SessionEnvironment' -Funct # IFNIQTM4NCAyMDIxIENBMQIQBNI793flHTneCMtwLiiYFTANBglghkgBZQMEAgEF # AKCBhDAYBgorBgEEAYI3AgEMMQowCKACgAChAoAAMBkGCSqGSIb3DQEJAzEMBgor # BgEEAYI3AgEEMBwGCisGAQQBgjcCAQsxDjAMBgorBgEEAYI3AgEVMC8GCSqGSIb3 -# DQEJBDEiBCAq3pBrLVvjp3b/NR42b+Azn+un2R42vwQvCAMjkoABCTANBgkqhkiG -# 9w0BAQEFAASCAYBb3hzofqnjQVyQd/ouNG7FFKpmYB7l63QPb58gcWcnm9Bom2yD -# FPtPmHGUlIA5ZOYoC5rRIAY2t9xOLOTcnKsDdIq65SPHBfG4oI3oBtCELvF6FGZF -# AEuFKQYBzO+xxxrAG83TNwJmv/evgEWV8iII+458Bk/1PgNHC1/nW7h0KBabF9lB -# iXrXSxGq8Fz4jjQSuVf16atDjPnwPnKl5KnMe3/gBTdx+ZpKHlp3wuBS2Kow5plr -# 5MY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RrHl49vBEfMWrEFUKLftX1h6fNK+yUwDQYJ +# KoZIhvcNAQEBBQAEggIACHYJ0+3kwIHcHHjKIDyuiSEVbOEILaKg04+t2U4pbvW6 +# lgtB5E0NdOGFmd21Dtkgk02BsVHlSCjOyLtbIEPT8ZaX0SNz37EOblUCTl8n6gwj +# eAFcZDp6Rtm+L/SBCq4BQOg4SCiTUB4FmspN1S0qHRM98lHKf7gTnwPTN5E7zRDQ +# 3z84RVmqdK0IqrwVtZx64CJeXBTnoi44Dw4AaS01OCaRuobW/FDaJXFRaqgjttVi +# 6I+DmF8sul931i8ySTS1alI/RezVkBnWaFqTVYeh8YOUDmxEqcq6XVVqF+cP8Ulh +# 0X9hgPFwJ/8pMILt+gwTiRiGBE3hv+IsipRmgz22LjbtcmYKbMjN5zp2tJTTJ1bM +# 5RFZlg4CRC4keFVa/R4uWsx7KDcS1twsZWAm/OyU4i+3DH28XpfV3iMOy/okXWHg +# hMGUbwdXr4bk5+KbuVMgfFw4WEh6NN8jtJyLHCzoFA0Tc/p3cnwKn9IFxnvLQlS9 +# ez3648Bp+LCEWNneZ8j9F6nowqBr9woGww86XEQuHOgc3GGJfqiRLZ7V+NG2X6OT +# yUyo1Zdb3++Bd2QOi2AnU4V0O+zIoDzcU6b7Qi569P2tVE0l62vqfp4lmp9wdJcd +# hwxODFnTQjo3751hZVmjAioeud86X6019CBFjk9o59tcB2oDDjhBqxiAr18CEp0= # SIG # End signature block From 6cbdb8272e512e748042462d9c54a270ec7e4469 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Tue, 28 May 2024 02:12:17 -0700 Subject: [PATCH 12/37] (doc) Change source code to match production docs While running the GenerateDocs.ps1 script, ahead of releasing version 2.3.0, it was found that the production docs has been updated to make some changes, for example, removal of older version numbers that no longer need to be displayed. This commit addresses this change in the production docs, but making the same change in the source code, so that the next time that GenerateDocs.ps1 is run, the output will better match what is already in place. --- .../infrastructure.app/builders/ConfigurationBuilder.cs | 4 ++-- .../infrastructure.app/commands/ChocolateyInstallCommand.cs | 4 ---- .../infrastructure.app/commands/ChocolateySearchCommand.cs | 1 - .../infrastructure.app/commands/ChocolateySourceCommand.cs | 4 ++-- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs index e4caec93cd..3d7be60ae5 100644 --- a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs +++ b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs @@ -340,7 +340,7 @@ private static void SetAllFeatureFlags(ChocolateyConfiguration config, ConfigFil config.Features.UsePackageRepositoryOptimizations = SetFeatureFlag(ApplicationParameters.Features.UsePackageRepositoryOptimizations, configFileSettings, defaultEnabled: true, description: "Use Package Repository Optimizations - Turn on optimizations for reducing bandwidth with repository queries during package install/upgrade/outdated operations. Should generally be left enabled, unless a repository needs to support older methods of query. When disabled, this makes queries similar to the way they were done in earlier versions of Chocolatey."); config.Features.UsePackageHashValidation = SetFeatureFlag(ApplicationParameters.Features.UsePackageHashValidation, configFileSettings, defaultEnabled: false, description: "Use Package Hash Validation - Check the hash of the downloaded package file against the source provided hash. Only supports sources that provide SHA512 hashes. Disabled by default. Available in 2.3.0+"); config.PromptForConfirmation = !SetFeatureFlag(ApplicationParameters.Features.AllowGlobalConfirmation, configFileSettings, defaultEnabled: false, description: "Prompt for confirmation in scripts or bypass."); - config.DisableCompatibilityChecks = SetFeatureFlag(ApplicationParameters.Features.DisableCompatibilityChecks, configFileSettings, defaultEnabled: false, description: "Disable Compatibility Checks - Disable showing a warning when there is an incompatibility between Chocolatey CLI and Chocolatey Licensed Extension. Available in 1.1.0+"); + config.DisableCompatibilityChecks = SetFeatureFlag(ApplicationParameters.Features.DisableCompatibilityChecks, configFileSettings, defaultEnabled: false, description: "Disable Compatibility Checks - Disable showing a warning when there is an incompatibility between Chocolatey CLI and Chocolatey Licensed Extension."); } private static bool SetFeatureFlag(string featureName, ConfigFileSettings configFileSettings, bool defaultEnabled, string description) @@ -456,7 +456,7 @@ private static void SetGlobalOptions(IList args, ChocolateyConfiguration "Log File to output to in addition to regular loggers.", option => config.AdditionalLogFileLocation = option.UnquoteSafe()) .Add("skipcompatibilitychecks|skip-compatibility-checks", - "SkipCompatibilityChecks - Prevent warnings being shown before and after command execution when a runtime compatibility problem is found between the version of Chocolatey and the Chocolatey Licensed Extension. Available in 1.1.0+", + "SkipCompatibilityChecks - Prevent warnings being shown before and after command execution when a runtime compatibility problem is found between the version of Chocolatey and the Chocolatey Licensed Extension.", option => config.DisableCompatibilityChecks = option != null) .Add("ignore-http-cache", "IgnoreHttpCache - Ignore any HTTP caches that have previously been created when querying sources, and create new caches. Available in 2.1.0+", diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs index 7364a59fd4..45bf7cf207 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs @@ -279,10 +279,6 @@ Installs a package or a list of packages (sometimes specified as a "chocolatey".Log().Info(@" choco install [ ] [] -NOTE: `all` is a special package keyword that will allow you to install - all packages from a custom feed. Will not work with Chocolatey default - feed. THIS IS NOT YET REIMPLEMENTED. - NOTE: Any package name ending with .config is considered a 'packages.config' file. Please see https://ch0.co/packages_config diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateySearchCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateySearchCommand.cs index af4766f71e..2bf9d85959 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateySearchCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateySearchCommand.cs @@ -212,7 +212,6 @@ file a ticket so we can document it at choco {0}: https://raw.githubusercontent.com/wiki/chocolatey/choco/images/gifs/choco_search.gif ".FormatWith(configuration.CommandName)); - "chocolatey".Log().Info(ChocolateyLoggers.Important, "Alternative Sources"); "chocolatey".Log().Info(ChocolateyLoggers.Important, "Options and Switches"); } diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateySourceCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateySourceCommand.cs index 874d4471e3..12c3981bd0 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateySourceCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateySourceCommand.cs @@ -70,10 +70,10 @@ public virtual void ConfigureArgumentParser(OptionSet optionSet, ChocolateyConfi "Bypass Proxy - Should this source explicitly bypass any explicitly or system configured proxies? Defaults to false.", option => configuration.SourceCommand.BypassProxy = option != null) .Add("allowselfservice|allow-self-service", - "Allow Self-Service - Should this source be allowed to be used with self-service? Requires business edition (v1.10.0+) with feature 'useBackgroundServiceWithSelfServiceSourcesOnly' turned on. Defaults to false.", + "Allow Self-Service - Should this source be allowed to be used with self-service? Requires business edition with feature 'useBackgroundServiceWithSelfServiceSourcesOnly' turned on. Defaults to false.", option => configuration.SourceCommand.AllowSelfService = option != null) .Add("adminonly|admin-only", - "Visible to Administrators Only - Should this source be visible to non-administrators? Requires business edition (v1.12.2+). Defaults to false.", + "Visible to Administrators Only - Should this source be visible to non-administrators? Requires business edition. Defaults to false.", option => configuration.SourceCommand.VisibleToAdminsOnly = option != null) ; } From 67cf4ed806d976acebb2d71e7cc5931a619a7a3a Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Tue, 28 May 2024 08:52:31 -0700 Subject: [PATCH 13/37] (maint) Fix initialization for VerifiyContainer In a previous commit: https://github.com/chocolatey/choco/commit/8c422301e4589b879d866e710d1261abf0bdab4e#diff-56c83e4e3e69e032ca2de3fefe172645908c9db983ef1a9080cc3aa87ea5b773R45 A change was made to fix IDE0032 on some parts of the SimpleInjectorContainer class. However, the change that was made missed the fact that there was a compiler directive in place that changed the default value for the property. While in debug mode, it defaulted to true, but in anything else, it defaulted to false. Initially during testing, this didn't cause any problems, however, when using Chocolatey Agent, it caused errors to occur during start up of the service. This was due to the fact that in Chocolatey Agent some additional IoC registrations are performed, but with the default value now set to true, the Verify method on the container instance was being called, which then prevents any additional registrations from being allowed, which meant the Chocolatey Agent service couldn't be started. This commit puts back in place the default values for the property, using the exisitng cmpilers directives. --- .../infrastructure/registration/SimpleInjectorContainer.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/chocolatey/infrastructure/registration/SimpleInjectorContainer.cs b/src/chocolatey/infrastructure/registration/SimpleInjectorContainer.cs index 595405dd7b..1261c869f6 100644 --- a/src/chocolatey/infrastructure/registration/SimpleInjectorContainer.cs +++ b/src/chocolatey/infrastructure/registration/SimpleInjectorContainer.cs @@ -38,12 +38,11 @@ public static class SimpleInjectorContainer private const string RegisterComponentsMethod = "RegisterComponents"; #if DEBUG + public static bool VerifyContainer { get; set; } = true; #else - private static bool _verifyContainer = false; + public static bool VerifyContainer { get; set; } = false; #endif - public static bool VerifyContainer { get; set; } = true; - /// /// Add a component registry class to the container. /// Must have `public void RegisterComponents(Container container)` From 4324eed9ef0c225f5ce2d0585c5821f43b50b69e Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Wed, 22 May 2024 08:10:21 -0700 Subject: [PATCH 14/37] (#1762) Add test for new enhanced exit code Now, when you have useEnhancedExitCodes turned on, if you try to set a pin on a package, that is already set, the exit code will change to be a 2, giving a clear indication that no action was taken. This commit adds a Pester test to verify that this works as expected. --- .../pester-tests/commands/choco-pin.Tests.ps1 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/pester-tests/commands/choco-pin.Tests.ps1 b/tests/pester-tests/commands/choco-pin.Tests.ps1 index 465b434cf7..7e8f0e0725 100644 --- a/tests/pester-tests/commands/choco-pin.Tests.ps1 +++ b/tests/pester-tests/commands/choco-pin.Tests.ps1 @@ -112,6 +112,24 @@ Describe "choco pin" -Tag Chocolatey, PinCommand { $Output.Lines | Should -Contain "Nothing to change. Pin already set or removed." $CurrentPins | Should -Contain "upgradepackage|1.0.0$listSuffix" } + + Context "when using enhanced exit codes" { + BeforeAll { + $null = Enable-ChocolateyFeature -Name "useEnhancedExitCodes" + + $Output = Invoke-Choco pin add --name upgradepackage + $CurrentPins = Invoke-Choco pin list --LimitOutput | ForEach-Object Lines + } + + It "Exits with ExitCode 2" { + $Output.ExitCode | Should -Be 2 -Because $Output.String + } + + It "Changes Nothing" { + $Output.Lines | Should -Contain "Nothing to change. Pin already set or removed." + $CurrentPins | Should -Contain "upgradepackage|1.0.0$listSuffix" + } + } } Context "Setting a Pin for a non-installed Package" { From 6acb5a0f5827fd2952ca9930c92b02dc3c409d2b Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 23 May 2024 00:48:59 -0700 Subject: [PATCH 15/37] (#1761) Add test for new enhanced exit code Now, when you have useEnhancedExitCodes turned on, if you try to enable/disable a feature that is already in the desired state, the exit code will change to be a 2, giving a clear indication that no action was taken. This commit adds a Pester test to verify that this works as expected. --- .../commands/choco-feature.Tests.ps1 | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/tests/pester-tests/commands/choco-feature.Tests.ps1 b/tests/pester-tests/commands/choco-feature.Tests.ps1 index 21322d8b78..48acb6a4ce 100644 --- a/tests/pester-tests/commands/choco-feature.Tests.ps1 +++ b/tests/pester-tests/commands/choco-feature.Tests.ps1 @@ -112,6 +112,76 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, FeatureCommand { } } + Context "Enabling a feature when it is already enabled" { + BeforeAll { + Restore-ChocolateyInstallSnapshot + + # Ensure that the feature is already enabled + $null = Invoke-Choco feature enable --name allowGlobalConfirmation + + $Output = Invoke-Choco feature enable --name allowGlobalConfirmation + } + + It "Exits with ExitCode 0" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Changes Nothing" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + + Context "when using enhanced exit codes" { + BeforeAll { + $null = Enable-ChocolateyFeature -Name "useEnhancedExitCodes" + + $Output = Invoke-Choco feature enable --name allowGlobalConfirmation + } + + It "Exits with ExitCode 2" { + $Output.ExitCode | Should -Be 2 -Because $Output.String + } + + It "Changes Nothing" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + } + } + + Context "Disabling a feature when it is already disabled" { + BeforeAll { + Restore-ChocolateyInstallSnapshot + + # Ensure that the feature is already disabled + $null = Invoke-Choco feature disable --name allowGlobalConfirmation + + $Output = Invoke-Choco feature disable --name allowGlobalConfirmation + } + + It "Exits with ExitCode 0" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Changes Nothing" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + + Context "when using enhanced exit codes" { + BeforeAll { + $null = Enable-ChocolateyFeature -Name "useEnhancedExitCodes" + + $Output = Invoke-Choco feature disable --name allowGlobalConfirmation + } + + It "Exits with ExitCode 2" { + $Output.ExitCode | Should -Be 2 -Because $Output.String + } + + It "Changes Nothing" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + } + } + Context "Disabling usePackageRepositoryOptimizations" { BeforeAll { Restore-ChocolateyInstallSnapshot From f21cc6c1ca80d34018e4980fd513fe5ef5f790b2 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 23 May 2024 01:10:21 -0700 Subject: [PATCH 16/37] (#1759) Add test for new enhanced exit code Now, when you have useEnhancedExitCodes turned on, if you try to add an apikey when it is already added the exit code will change to be a 2, giving a clear indication that no action was taken. This commit adds a Pester test to verify that this works as expected. --- .../commands/choco-apikey.Tests.ps1 | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/pester-tests/commands/choco-apikey.Tests.ps1 b/tests/pester-tests/commands/choco-apikey.Tests.ps1 index 5ed9daf81f..9660a61c30 100644 --- a/tests/pester-tests/commands/choco-apikey.Tests.ps1 +++ b/tests/pester-tests/commands/choco-apikey.Tests.ps1 @@ -371,6 +371,41 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand { } } + Context "Adding an apikey when it is already added" { + BeforeAll { + Restore-ChocolateyInstallSnapshot + + # Ensure that the apikey is indeed set + $null = Invoke-Choco apikey add --source "https://somewhere.out/there/" --api-key "123-4567-89" + + $Output = Invoke-Choco apikey add --source "https://somewhere.out/there/" --api-key "123-4567-89" + } + + It "Exits with ExitCode 0" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Changes Nothing" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + + Context "when using enhanced exit codes" { + BeforeAll { + $null = Enable-ChocolateyFeature -Name "useEnhancedExitCodes" + + $Output = Invoke-Choco apikey add --source "https://somewhere.out/there/" --api-key "123-4567-89" + } + + It "Exits with ExitCode 2" { + $Output.ExitCode | Should -Be 2 -Because $Output.String + } + + It "Changes Nothing" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + } + } + # This needs to be the last test in this block, to ensure NuGet configurations aren't being created. Test-NuGetPaths } From 6ff132be27b5968b3c39ea6a6c716328ca6c7b40 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 23 May 2024 01:36:40 -0700 Subject: [PATCH 17/37] (#1760) Add test for new enhanced exit code Now, when you have useEnhancedExitCodes turned on, if you try to unset a config value that doesn't exist, or try to set a config value where the value is already set to that value, the exit code will change to be a 2, giving a clear indication that no action was taken. This commit adds a Pester test to verify that this works as expected. --- .../commands/choco-config.Tests.ps1 | 51 ++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/tests/pester-tests/commands/choco-config.Tests.ps1 b/tests/pester-tests/commands/choco-config.Tests.ps1 index 92868b84a3..3822126ba1 100644 --- a/tests/pester-tests/commands/choco-config.Tests.ps1 +++ b/tests/pester-tests/commands/choco-config.Tests.ps1 @@ -175,6 +175,38 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand { } } + Context "Setting a configuration setting (cacheLocation) with same value that already exists" { + BeforeAll { + $null = Invoke-Choco config set cacheLocation "C:\temp\choco" + + $Output = Invoke-Choco config set cacheLocation "C:\temp\choco" + } + + It "Exits with Success (0)" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Changes Nothing" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + + Context "when using enhanced exit codes" { + BeforeAll { + $null = Enable-ChocolateyFeature -Name "useEnhancedExitCodes" + + $Output = Invoke-Choco config set cacheLocation "C:\temp\choco" + } + + It "Exits with ExitCode 2" { + $Output.ExitCode | Should -Be 2 -Because $Output.String + } + + It "Changes Nothing" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + } + } + Context "Setting a configuration setting not available by default (newConfiguration)" { BeforeAll { $Output = Invoke-Choco config set --name newConfiguration --value some-value @@ -261,6 +293,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand { Context "Unsetting a configuration that doesn't exist" { BeforeAll { + $null = Disable-ChocolateyFeature -Name "useEnhancedExitCodes" $Output = Invoke-Choco config unset not-existing [xml]$ConfigFileContent = Get-Content $env:ChocolateyInstall\config\chocolatey.config @@ -275,7 +308,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand { $Output.Lines | Should -Contain $expectedLicenseHeader } - It "Displays config value Added" { + It "Changes nothing" { $Output.Lines | Should -Contain "Nothing to change. Config already set." } @@ -283,6 +316,22 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand { $value = $configs.Where{ $_.key -eq "not-existing" } $value | Should -HaveCount 0 } + + Context "when using enhanced exit codes" { + BeforeAll { + $null = Enable-ChocolateyFeature -Name "useEnhancedExitCodes" + + $Output = Invoke-Choco config unset not-existing + } + + It "Exits with ExitCode 2" { + $Output.ExitCode | Should -Be 2 -Because $Output.String + } + + It "Changes Nothing" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + } } # This needs to be the last test in this block, to ensure NuGet configurations aren't being created. From fdbbb2c177dc8e366bba4f5c15784f55ff6142a5 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 23 May 2024 02:37:59 -0700 Subject: [PATCH 18/37] (#1764) Add test for new enhanced exit code Now, when you have useEnhancedExitCodes turned on, if you try to add an already existing source, remove a source that doesn't exist, disable a source that is already disabled, or enable a source that is already enabled, the exit code will change to be a 2, giving a clear indication that no action was taken. This commit adds a Pester test to verify that this works as expected. --- .../commands/choco-source.Tests.ps1 | 172 ++++++++++++++++++ 1 file changed, 172 insertions(+) diff --git a/tests/pester-tests/commands/choco-source.Tests.ps1 b/tests/pester-tests/commands/choco-source.Tests.ps1 index 701550edad..2c9035662c 100644 --- a/tests/pester-tests/commands/choco-source.Tests.ps1 +++ b/tests/pester-tests/commands/choco-source.Tests.ps1 @@ -67,6 +67,45 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { } } + Context "Add source that already exists" { + BeforeAll { + $null = Disable-ChocolateyFeature -Name "useEnhancedExitCodes" + + # Ensure source is already added + Invoke-Choco $CurrentCommand add --name "already-exists" --source "https://somewhere/out/there/" + + $Output = Invoke-Choco $CurrentCommand add --name "already-exists" --source "https://somewhere/out/there/" + } + + It "Exits with Success (0)" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Displays chocolatey name with version" { + $Output.Lines | Should -Contain $expectedHeader + } + + It "Displays no change made" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + + Context "when using enhanced exit codes" { + BeforeAll { + $null = Enable-ChocolateyFeature -Name "useEnhancedExitCodes" + + $Output = Invoke-Choco $CurrentCommand add --name "already-exists" --source "https://somewhere/out/there/" + } + + It "Exits with ExitCode 2" { + $Output.ExitCode | Should -Be 2 -Because $Output.String + } + + It "Changes Nothing" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + } + } + Context "Add single unauthenticated source with priority" { BeforeAll { $Output = Invoke-Choco $CurrentCommand add --name "dummy-long" --source "https://priority.test.com/api" --priority 1 @@ -304,6 +343,8 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { Context "Removing missing source" { BeforeAll { + $null = Disable-ChocolateyFeature -Name "useEnhancedExitCodes" + # Make sure the source is removed Invoke-Choco $CurrentCommand remove --name "not-existing" @@ -321,6 +362,22 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { It "Displays message about no change made" { $Output.Lines | Should -Contain "Nothing to change. Config already set." } + + Context "when using enhanced exit codes" { + BeforeAll { + $null = Enable-ChocolateyFeature -Name "useEnhancedExitCodes" + + $Output = Invoke-Choco $CurrentCommand remove --name "not-existing" + } + + It "Exits with ExitCode 2" { + $Output.ExitCode | Should -Be 2 -Because $Output.String + } + + It "Changes Nothing" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + } } Context "Disabling existing source" { @@ -387,6 +444,8 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { Context "Disabling missing source" { BeforeAll { + $null = Disable-ChocolateyFeature -Name "useEnhancedExitCodes" + # Ensure source is not available Invoke-Choco $CurrentCommand remove --name "not-existing" @@ -404,10 +463,68 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { It "Displays no change made" { $Output.Lines | Should -Contain "Nothing to change. Config already set." } + + Context "when using enhanced exit codes" { + BeforeAll { + $null = Enable-ChocolateyFeature -Name "useEnhancedExitCodes" + + $Output = Invoke-Choco $CurrentCommand disable --name "not-existing" + } + + It "Exits with ExitCode 2" { + $Output.ExitCode | Should -Be 2 -Because $Output.String + } + + It "Changes Nothing" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + } + } + + Context "Disabling source that is already disabled" { + BeforeAll { + $null = Disable-ChocolateyFeature -Name "useEnhancedExitCodes" + + # Ensure source is not available + Invoke-Choco $CurrentCommand add --name "already-disabled" --source "https://somewhere/out/there/" + Invoke-Choco $CurrentCommand disable --name "already-disabled" + + $Output = Invoke-Choco $CurrentCommand disable --name "already-disabled" + } + + It "Exits with Success (0)" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Displays chocolatey name with version" { + $Output.Lines | Should -Contain $expectedHeader + } + + It "Displays no change made" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + + Context "when using enhanced exit codes" { + BeforeAll { + $null = Enable-ChocolateyFeature -Name "useEnhancedExitCodes" + + $Output = Invoke-Choco $CurrentCommand disable --name "already-disabled" + } + + It "Exits with ExitCode 2" { + $Output.ExitCode | Should -Be 2 -Because $Output.String + } + + It "Changes Nothing" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + } } Context "Enabling missing source" { BeforeAll { + $null = Disable-ChocolateyFeature -Name "useEnhancedExitCodes" + # Ensure source is not available Invoke-Choco $CurrentCommand remove --name "not-existing" @@ -425,6 +542,61 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { It "Displays no change made" { $Output.Lines | Should -Contain "Nothing to change. Config already set." } + + Context "when using enhanced exit codes" { + BeforeAll { + $null = Enable-ChocolateyFeature -Name "useEnhancedExitCodes" + + $Output = Invoke-Choco $CurrentCommand enable --name "not-existing" + } + + It "Exits with ExitCode 2" { + $Output.ExitCode | Should -Be 2 -Because $Output.String + } + + It "Changes Nothing" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + } + } + + Context "Enabling source that is already enabled" { + BeforeAll { + $null = Disable-ChocolateyFeature -Name "useEnhancedExitCodes" + + # Ensure source is enable + Invoke-Choco $CurrentCommand add --name "already-enabled" --source "https://somewhere/out/there/" + + $Output = Invoke-Choco $CurrentCommand enable --name "already-enabled" + } + + It "Exits with Success (0)" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Displays chocolatey name with version" { + $Output.Lines | Should -Contain $expectedHeader + } + + It "Displays no change made" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + + Context "when using enhanced exit codes" { + BeforeAll { + $null = Enable-ChocolateyFeature -Name "useEnhancedExitCodes" + + $Output = Invoke-Choco $CurrentCommand enable --name "already-enabled" + } + + It "Exits with ExitCode 2" { + $Output.ExitCode | Should -Be 2 -Because $Output.String + } + + It "Changes Nothing" { + $Output.Lines | Should -Contain "Nothing to change. Config already set." + } + } } # This needs to be the last test in this block, to ensure NuGet configurations aren't being created. From d7a401848df591540060b7489e267813fb7e0f3d Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 23 May 2024 03:05:31 -0700 Subject: [PATCH 19/37] (#2200) Add test for new enhanced exit code Now, when you have useEnhancedExitCodes turned on, if you try to upgrade a package, whether directly, or via the all keyword, and there are no upgrade available, the exit code will change to be a 2, giving a clear indication that no action was taken. This commit adds a Pester test to verify that this works as expected. --- .../commands/choco-upgrade.Tests.ps1 | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/tests/pester-tests/commands/choco-upgrade.Tests.ps1 b/tests/pester-tests/commands/choco-upgrade.Tests.ps1 index 1521a0bf7c..8346d9dde8 100644 --- a/tests/pester-tests/commands/choco-upgrade.Tests.ps1 +++ b/tests/pester-tests/commands/choco-upgrade.Tests.ps1 @@ -73,6 +73,77 @@ } } + Context "Attempt to upgrade a package when there isn't an upgrade available" -Tag Internal { + BeforeAll { + Restore-ChocolateyInstallSnapshot + + Enable-ChocolateySource -Name hermes-setup + $null = Invoke-Choco install wget + + $Output = Invoke-Choco upgrade wget + } + + It 'Exits with Success (0)' { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It 'Displays that upgrade was attempted but wasnt required' { + $Output.Lines | Should -Contain "Chocolatey upgraded 0/1 packages." -Because $Output.String + } + + Context "when using enhanced exit codes" { + BeforeAll { + $null = Enable-ChocolateyFeature -Name "useEnhancedExitCodes" + + $Output = Invoke-Choco upgrade wget + } + + It "Exits with ExitCode 2" { + $Output.ExitCode | Should -Be 2 -Because $Output.String + } + + It 'Displays that upgrade was attempted but wasnt required' { + $Output.Lines | Should -Contain "Chocolatey upgraded 0/1 packages." -Because $Output.String + } + } + } + + Context "Attempt to run upgrade all when there isn't any upgrade available" -Tag Internal { + BeforeAll { + Restore-ChocolateyInstallSnapshot + + Enable-ChocolateySource -Name hermes-setup + $null = Invoke-Choco install wget + $null = Invoke-Choco install curl + + $Output = Invoke-Choco upgrade all + } + + It 'Exits with Success (0)' { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It 'Displays that upgrade was attempted but wasnt required' { + $Output.Lines | Should -Contain "Chocolatey upgraded 0/2 packages." -Because $Output.String + } + + Context "when using enhanced exit codes" { + BeforeAll { + $null = Enable-ChocolateyFeature -Name "useEnhancedExitCodes" + + $Output = Invoke-Choco upgrade all + } + + It "Exits with ExitCode 2" { + $Output.ExitCode | Should -Be 2 -Because $Output.String + } + + It 'Displays that upgrade was attempted but wasnt required' { + $Output.Lines | Should -Contain "Chocolatey upgraded 0/2 packages." -Because $Output.String + } + } + } + # We exclude this test when running CCM, as it will install and remove # the firefox package which is used through other tests that will be affected. Context "Upgrading packages while remembering arguments with multiple packages using arguments" -Tag CCMExcluded, Internal, VMOnly { From 9205c4d2aada0aa01ac259e83fbf05c8466df60d Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 23 May 2024 07:37:06 -0700 Subject: [PATCH 20/37] (#23) Add tests to handle install all This commit adds some Pester tests to ensure that any attempts to run the choco install all command is correctly handled when targeting an alternative source. This is simply asserting that there is an error exit code, and that the correct output is displayed. Some of the new tests are specifically set to only run on Test-Kitchen, as there is the potential for changes to happen on the host machine, and we don't want to impact people. --- .../features/CygwinSource.Tests.ps1 | 30 +++++++++++++++++++ .../features/PythonSource.Tests.ps1 | 23 ++++++++++++-- .../features/RubySource.Tests.ps1 | 30 +++++++++++++++++++ .../features/WindowsFeaturesSource.Tests.ps1 | 26 ++++++++++++++++ 4 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 tests/pester-tests/features/CygwinSource.Tests.ps1 create mode 100644 tests/pester-tests/features/RubySource.Tests.ps1 create mode 100644 tests/pester-tests/features/WindowsFeaturesSource.Tests.ps1 diff --git a/tests/pester-tests/features/CygwinSource.Tests.ps1 b/tests/pester-tests/features/CygwinSource.Tests.ps1 new file mode 100644 index 0000000000..90f3b78ef6 --- /dev/null +++ b/tests/pester-tests/features/CygwinSource.Tests.ps1 @@ -0,0 +1,30 @@ +Import-Module helpers/common-helpers + +# This is skipped when not run in CI because it modifies the local system. +Describe "Cygwin Source" -Tag Chocolatey, CygwinSource -Skip:(-not $env:TEST_KITCHEN) { + BeforeAll { + Initialize-ChocolateyTestInstall + New-ChocolateyInstallSnapshot + Enable-ChocolateySource -Name hermes-setup + $null = Invoke-Choco install cygwin + } + + AfterAll { + $null = Invoke-Choco uninstall cygwin --remove-dependencies + Remove-ChocolateyTestInstall + } + + Context "install all" { + BeforeAll { + $Output = Invoke-Choco install all --source=cygwin + } + + It 'Exits with exit code (1)' { + $Output.ExitCode | Should -Be 1 -Because $Output.String + } + + It 'Outputs exception' { + $Output.Lines | Should -Contain "Alternative sources do not allow the use of the 'all' package name/keyword." -Because $Output.String + } + } +} \ No newline at end of file diff --git a/tests/pester-tests/features/PythonSource.Tests.ps1 b/tests/pester-tests/features/PythonSource.Tests.ps1 index 63d91cf424..2a0aad6b67 100644 --- a/tests/pester-tests/features/PythonSource.Tests.ps1 +++ b/tests/pester-tests/features/PythonSource.Tests.ps1 @@ -27,12 +27,29 @@ Describe "Python Source" -Tag Chocolatey, UpgradeCommand, PythonSource, ProxySki } It 'Exits with correct exit code ()' { - $Output.ExitCode | Should -Be $ExitCode + $Output.ExitCode | Should -Be $ExitCode -Because $Output.String } It 'Outputs properly' { - $Output.Lines | Should -Not:($ExitCode -eq 0) -Contain "Alternative sources do not allow the use of the 'all' package name/keyword." - $Output.Lines | Should -Contain "Chocolatey upgraded $Count/$Count packages." + $Output.Lines | Should -Not:($ExitCode -eq 0) -Contain "Alternative sources do not allow the use of the 'all' package name/keyword." -Because $Output.String + $Output.Lines | Should -Contain "Chocolatey upgraded $Count/$Count packages." -Because $Output.String + } + } + + Context "install all" { + BeforeAll { + # For some reason under kitchen-pester we don't have pip on the path. This might be due to our snapshotting... + Import-Module $env:ChocolateyInstall/helpers/ChocolateyProfile.psm1 + Update-SessionEnvironment + $Output = Invoke-Choco install all --source=python + } + + It 'Exits with exit code (1)' { + $Output.ExitCode | Should -Be 1 -Because $Output.String + } + + It 'Outputs exception' { + $Output.Lines | Should -Contain "Alternative sources do not allow the use of the 'all' package name/keyword." -Because $Output.String } } } diff --git a/tests/pester-tests/features/RubySource.Tests.ps1 b/tests/pester-tests/features/RubySource.Tests.ps1 new file mode 100644 index 0000000000..83aba65f82 --- /dev/null +++ b/tests/pester-tests/features/RubySource.Tests.ps1 @@ -0,0 +1,30 @@ +Import-Module helpers/common-helpers + +# This is skipped when not run in CI because it modifies the local system. +Describe "Ruby Source" -Tag Chocolatey, RubySource -Skip:(-not $env:TEST_KITCHEN) { + BeforeAll { + Initialize-ChocolateyTestInstall + New-ChocolateyInstallSnapshot + Enable-ChocolateySource -Name hermes-setup + $null = Invoke-Choco install ruby.portable + } + + AfterAll { + $null = Invoke-Choco uninstall ruby.portable --remove-dependencies + Remove-ChocolateyTestInstall + } + + Context "install all" { + BeforeAll { + $Output = Invoke-Choco install all --source=ruby + } + + It 'Exits with exit code (1)' { + $Output.ExitCode | Should -Be 1 -Because $Output.String + } + + It 'Outputs exception' { + $Output.Lines | Should -Contain "Alternative sources do not allow the use of the 'all' package name/keyword." -Because $Output.String + } + } +} \ No newline at end of file diff --git a/tests/pester-tests/features/WindowsFeaturesSource.Tests.ps1 b/tests/pester-tests/features/WindowsFeaturesSource.Tests.ps1 new file mode 100644 index 0000000000..53bd633ea0 --- /dev/null +++ b/tests/pester-tests/features/WindowsFeaturesSource.Tests.ps1 @@ -0,0 +1,26 @@ +Import-Module helpers/common-helpers + +Describe "Windows Features Source" -Tag Chocolatey, WindowsFeaturesSource { + BeforeAll { + Initialize-ChocolateyTestInstall + New-ChocolateyInstallSnapshot + } + + AfterAll { + Remove-ChocolateyTestInstall + } + + Context "install all" { + BeforeAll { + $Output = Invoke-Choco install all --source=windowsfeatures + } + + It 'Exits with exit code (1)' { + $Output.ExitCode | Should -Be 1 -Because $Output.String + } + + It 'Outputs exception' { + $Output.Lines | Should -Contain "Alternative sources do not allow the use of the 'all' package name/keyword." -Because $Output.String + } + } +} \ No newline at end of file From 579d316b28d6148b4529beb78b5584f66cc3bfc0 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 23 May 2024 07:55:15 -0700 Subject: [PATCH 21/37] (#1310) Add Pester test to validate output Remembered arguments can now be displayed when running the choco info command, using the --local-only option. This commit adds a test to verify that this is correctly shown. --- .../commands/choco-info.Tests.ps1 | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/pester-tests/commands/choco-info.Tests.ps1 b/tests/pester-tests/commands/choco-info.Tests.ps1 index bc3eaa1a47..cc6bf7833f 100644 --- a/tests/pester-tests/commands/choco-info.Tests.ps1 +++ b/tests/pester-tests/commands/choco-info.Tests.ps1 @@ -12,6 +12,26 @@ Remove-ChocolateyTestInstall } + Context "Should include remembered arguments (including redacted) when using option --local-only" { + BeforeAll { + Remove-NuGetPaths + Initialize-ChocolateyTestInstall -Source $PSScriptRoot\testpackages + Invoke-Choco install installpackage --package-parameters="bob" --user="bill" --password="secure-password" --confirm + + $Output = Invoke-Choco info installpackage --local-only + } + + It "Exits with Success (0)" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Should contain a summary" { + $Output.Lines | Should -Contain "Remembered Package Arguments:" -Because $Output.String + $Output.Lines | Should -Contain "--package-parameters='bob'" -Because $Output.String + $Output.Lines | Should -Contain "--password=[REDACTED ARGUMENT]" -Because $Output.String + } + } + Context "Listing package information when package can be found" { BeforeDiscovery { $infoItems = @( @@ -187,11 +207,11 @@ } It 'Outputs warning about unable to load service index' { - $Output.Lines | Should -Contain "Unable to load the service index for source $InvalidSource." + $Output.Lines | Should -Contain "Unable to load the service index for source $InvalidSource." -Because $Output.String } It 'Output information about the package' { - $Output.String | Should -Match "Title: Chocolatey " + $Output.String | Should -Match "Title: Chocolatey " -Because $Output.String } } From a9e16851a393d26f302cb0355b740c39a4347a05 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Fri, 24 May 2024 00:44:26 -0700 Subject: [PATCH 22/37] (test) Update assertions for push commands Something has changed in the output that is coming back from the CCR when pushing a package, and that package fails. It is not immediately clear what has changed, but the assertions are being updated to allow the tests to pass, and we can monitor this going forward to see if something changes again. --- tests/pester-tests/commands/choco-push.Tests.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/pester-tests/commands/choco-push.Tests.ps1 b/tests/pester-tests/commands/choco-push.Tests.ps1 index 429503aa51..63a2a002f6 100644 --- a/tests/pester-tests/commands/choco-push.Tests.ps1 +++ b/tests/pester-tests/commands/choco-push.Tests.ps1 @@ -40,8 +40,8 @@ Describe "choco push" -Tag Chocolatey, PushCommand, ProxySkip -Skip:($null -eq $ It "Should Report the actual cause of the error" { $Output.Lines | Should -Contain "Attempting to push $PackageUnderTest.$VersionUnderTest.nupkg to $RepositoryToUse" -Because $Output.String - $Output.Lines | Should -Contain "An error has occurred. It's possible the package version already exists on the repository or a nuspec element is invalid. See error below..." -Because $Output.String - $Output.Lines | Should -Contain "Response status code does not indicate success: 409 (Conflict)." -Because $Output.String + $Output.Lines | Should -Contain "An error has occurred. This package version already exists on the repository and cannot be modified." -Because $Output.String + $Output.Lines | Should -Contain "Package versions that are approved, rejected, or exempted cannot be modified." -Because $Output.String } } @@ -71,7 +71,7 @@ Describe "choco push" -Tag Chocolatey, PushCommand, ProxySkip -Skip:($null -eq $ It "Should Report the actual cause of the error" { $Output.Lines | Should -Contain "Attempting to push $PackageUnderTest.$VersionUnderTest.nupkg to $RepositoryToUse" -Because $Output.String $Output.Lines | Should -Contain "An error has occurred. It's possible the package version already exists on the repository or a nuspec element is invalid. See error below..." -Because $Output.String - $Output.Lines | Should -Contain "Response status code does not indicate success: 409 (Conflict)." -Because $Output.String + $Output.Lines | Should -Contain "Response status code does not indicate success: 409 (This package had an issue pushing: A nuget package's Description property may not be more than 4000 characters long.)." -Because $Output.String } } @@ -101,7 +101,7 @@ Describe "choco push" -Tag Chocolatey, PushCommand, ProxySkip -Skip:($null -eq $ It "Should Report the actual cause of the error" { $Output.Lines | Should -Contain "Attempting to push $PackageUnderTest.$VersionUnderTest.nupkg to $RepositoryToUse" -Because $Output.String $Output.Lines | Should -Contain "An error has occurred. It's possible the package version already exists on the repository or a nuspec element is invalid. See error below..." -Because $Output.String - $Output.Lines | Should -Contain "Response status code does not indicate success: 409 (Conflict)." -Because $Output.String + $Output.Lines | Should -Contain "Response status code does not indicate success: 409 (This package had an issue pushing: A nuget package's Title property may not be more than 256 characters long.)." -Because $Output.String } } From b28de4fef1cdd2232c2f5288b83e0636c1066d45 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Fri, 24 May 2024 01:27:14 -0700 Subject: [PATCH 23/37] (#72) Add Pester tests to cover new functionality In these release, it is now possible to include already configured sources, i.e. in the chocolatey.config file, using an option on the info, install, outdated, search, and upgrade commands. This commit adds tests to cover these being included. --- .../commands/choco-info.Tests.ps1 | 18 +++++ .../commands/choco-install.Tests.ps1 | 70 +++++++++++++++++++ .../commands/choco-outdated.Tests.ps1 | 14 ++++ .../commands/choco-search.Tests.ps1 | 14 ++++ .../commands/choco-upgrade.Tests.ps1 | 19 +++++ 5 files changed, 135 insertions(+) diff --git a/tests/pester-tests/commands/choco-info.Tests.ps1 b/tests/pester-tests/commands/choco-info.Tests.ps1 index cc6bf7833f..d727aa461c 100644 --- a/tests/pester-tests/commands/choco-info.Tests.ps1 +++ b/tests/pester-tests/commands/choco-info.Tests.ps1 @@ -32,6 +32,24 @@ } } + Context "Should include configured sources" { + BeforeAll { + Remove-NuGetPaths + Initialize-ChocolateyTestInstall -Source $PSScriptRoot\testpackages + Invoke-Choco install installpackage --confirm + + $Output = Invoke-Choco info installpackage --include-configured-sources --debug + } + + It "Exits with Success (0)" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Should mention that configured sources have been included" { + $Output.Lines | Should -Contain "Including sources from chocolatey.config file." -Because $Output.String + } + } + Context "Listing package information when package can be found" { BeforeDiscovery { $infoItems = @( diff --git a/tests/pester-tests/commands/choco-install.Tests.ps1 b/tests/pester-tests/commands/choco-install.Tests.ps1 index 6f19163f24..aa58a25e61 100644 --- a/tests/pester-tests/commands/choco-install.Tests.ps1 +++ b/tests/pester-tests/commands/choco-install.Tests.ps1 @@ -143,6 +143,76 @@ } } + Context "Installing a Package (Happy Path) including configured sources" { + BeforeAll { + Restore-ChocolateyInstallSnapshot + + $PackageUnderTest = "installpackage" + + $Output = Invoke-Choco install $PackageUnderTest --include-configured-sources --debug --confirm + } + + It "Exits with Success (0)" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Installed a package to the lib directory" { + "$env:ChocolateyInstall\lib\$PackageUnderTest" | Should -Exist + } + + # We are skipping this for now, until we have stabilized the directory + # path reporting functionality. There are times that this test will + # fail due to Chocolatey not reporting the path. + # This failure seems to happen randomly, and is therefore not a + # reliable test we can make. + It "Outputs the installation directory (which should exist)" -Skip { + $directoryPath = "$env:ChocolateyInstall\lib\$PackageUnderTest" + $lineRegex = [regex]::Escape($directoryPath) + + $foundPath = $Output.Lines -match $lineRegex + $foundPath | Should -Not -BeNullOrEmpty + $foundPath | Should -Exist + } + + It "Installs the expected version of the package" { + "$env:ChocolateyInstall\lib\$PackageUnderTest\$PackageUnderTest.nuspec" | Should -Exist + [xml]$XML = Get-Content "$env:ChocolateyInstall\lib\$PackageUnderTest\$PackageUnderTest.nuspec" + $XML.package.metadata.version | Should -Be "1.0.0" + } + + It "Creates a Console Shim in the Bin Directory" { + "$env:ChocolateyInstall\bin\console.exe" | Should -Exist + } + + It "Creates a Graphical Shim in the Bin Directory" { + "$env:ChocolateyInstall\bin\graphical.exe" | Should -Exist + } + + It "Does not create a Shim for Ignored Executable in the Bin Directory" { + "$env:ChocolateyInstall\bin\not.installed.exe" | Should -Not -Exist + } + + It "Does not create a Shim for Ignored Executable (with mismatched case) in the Bin Directory" { + "$env:ChocolateyInstall\bin\casemismatch.exe" | Should -Not -Exist + } + + It "Does not create an extensions folder for the package" { + "$env:ChocolateyInstall\extensions\$PackageUnderTest" | Should -Not -Exist + } + + It "Contains the output of the ChocolateyInstall.ps1 script" { + $Output.Lines | Should -Contain "Ya!" + } + + It "Outputs a message showing that installation was successful" { + $Output.String | Should -Match "Chocolatey installed 1/1 packages\." + } + + It "Should mention that configured sources have been included" { + $Output.Lines | Should -Contain "Including sources from chocolatey.config file." -Because $Output.String + } + } + Context "Installing a Package with Packages.config" { BeforeAll { Restore-ChocolateyInstallSnapshot diff --git a/tests/pester-tests/commands/choco-outdated.Tests.ps1 b/tests/pester-tests/commands/choco-outdated.Tests.ps1 index c24de65af2..d269e95e49 100644 --- a/tests/pester-tests/commands/choco-outdated.Tests.ps1 +++ b/tests/pester-tests/commands/choco-outdated.Tests.ps1 @@ -23,6 +23,20 @@ Describe "choco outdated" -Tag Chocolatey, OutdatedCommand { Remove-ChocolateyTestInstall } + Context "Should include configured sources" { + BeforeAll { + $Output = Invoke-Choco outdated --include-configured-sources --debug + } + + It "Exits with Success (0)" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Should mention that configured sources have been included" { + $Output.Lines | Should -Contain "Including sources from chocolatey.config file." -Because $Output.String + } + } + Context "outdated ignore-pinned uses correct enhanced exit codes" -ForEach @( @{ Argument = '' ; ExitCode = 2 } @{ Argument = '--ignore-pinned' ; ExitCode = 0 } diff --git a/tests/pester-tests/commands/choco-search.Tests.ps1 b/tests/pester-tests/commands/choco-search.Tests.ps1 index 15b4fe5801..2aefee9dd4 100644 --- a/tests/pester-tests/commands/choco-search.Tests.ps1 +++ b/tests/pester-tests/commands/choco-search.Tests.ps1 @@ -64,6 +64,20 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SearchCommand, FindComma } } + Context "Should include configured sources" { + BeforeAll { + $Output = Invoke-Choco $_ upgradepackage --include-configured-sources --debug + } + + It "Exits with Success (0)" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Should mention that configured sources have been included" { + $Output.Lines | Should -Contain "Including sources from chocolatey.config file." -Because $Output.String + } + } + Context "Searching for a particular package" { BeforeAll { $Output = Invoke-Choco $_ upgradepackage diff --git a/tests/pester-tests/commands/choco-upgrade.Tests.ps1 b/tests/pester-tests/commands/choco-upgrade.Tests.ps1 index 8346d9dde8..1dc59ffa7d 100644 --- a/tests/pester-tests/commands/choco-upgrade.Tests.ps1 +++ b/tests/pester-tests/commands/choco-upgrade.Tests.ps1 @@ -73,6 +73,25 @@ } } + Context "Should include configured sources" { + BeforeAll { + Restore-ChocolateyInstallSnapshot + + Enable-ChocolateySource -Name hermes-setup + $null = Invoke-Choco install wget + + $Output = Invoke-Choco upgrade wget --include-configured-sources --debug + } + + It "Exits with Success (0)" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Should mention that configured sources have been included" { + $Output.Lines | Should -Contain "Including sources from chocolatey.config file." -Because $Output.String + } + } + Context "Attempt to upgrade a package when there isn't an upgrade available" -Tag Internal { BeforeAll { Restore-ChocolateyInstallSnapshot From 735331c2b07639280b238dade949dc55c898f46d Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Fri, 24 May 2024 01:33:44 -0700 Subject: [PATCH 24/37] (#1144) Add Pester test to cover hash validation In the next release, when possible, Chocolatey CLI will now include package hash validation to ensure that the package being installed is the one that the server thinks it is. This is a feature flag that needs to be toggled on. This commit adds tests to cover that hash validation is being attempted when it can be. --- .../commands/choco-install.Tests.ps1 | 82 ++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/tests/pester-tests/commands/choco-install.Tests.ps1 b/tests/pester-tests/commands/choco-install.Tests.ps1 index aa58a25e61..67b40473f2 100644 --- a/tests/pester-tests/commands/choco-install.Tests.ps1 +++ b/tests/pester-tests/commands/choco-install.Tests.ps1 @@ -83,7 +83,79 @@ $PackageUnderTest = "installpackage" - $Output = Invoke-Choco install $PackageUnderTest --confirm + $Output = Invoke-Choco install $PackageUnderTest --debug --confirm + } + + It "Exits with Success (0)" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Installed a package to the lib directory" { + "$env:ChocolateyInstall\lib\$PackageUnderTest" | Should -Exist + } + + # We are skipping this for now, until we have stabilized the directory + # path reporting functionality. There are times that this test will + # fail due to Chocolatey not reporting the path. + # This failure seems to happen randomly, and is therefore not a + # reliable test we can make. + It "Outputs the installation directory (which should exist)" -Skip { + $directoryPath = "$env:ChocolateyInstall\lib\$PackageUnderTest" + $lineRegex = [regex]::Escape($directoryPath) + + $foundPath = $Output.Lines -match $lineRegex + $foundPath | Should -Not -BeNullOrEmpty + $foundPath | Should -Exist + } + + It "Installs the expected version of the package" { + "$env:ChocolateyInstall\lib\$PackageUnderTest\$PackageUnderTest.nuspec" | Should -Exist + [xml]$XML = Get-Content "$env:ChocolateyInstall\lib\$PackageUnderTest\$PackageUnderTest.nuspec" + $XML.package.metadata.version | Should -Be "1.0.0" + } + + It "Creates a Console Shim in the Bin Directory" { + "$env:ChocolateyInstall\bin\console.exe" | Should -Exist + } + + It "Creates a Graphical Shim in the Bin Directory" { + "$env:ChocolateyInstall\bin\graphical.exe" | Should -Exist + } + + It "Does not create a Shim for Ignored Executable in the Bin Directory" { + "$env:ChocolateyInstall\bin\not.installed.exe" | Should -Not -Exist + } + + It "Does not create a Shim for Ignored Executable (with mismatched case) in the Bin Directory" { + "$env:ChocolateyInstall\bin\casemismatch.exe" | Should -Not -Exist + } + + It "Does not create an extensions folder for the package" { + "$env:ChocolateyInstall\extensions\$PackageUnderTest" | Should -Not -Exist + } + + It "Contains the output of the ChocolateyInstall.ps1 script" { + $Output.Lines | Should -Contain "Ya!" + } + + It "Outputs a message showing that installation was successful" { + $Output.String | Should -Match "Chocolatey installed 1/1 packages\." + } + + It "Should mention that package hash verification has been skipped" { + $Output.Lines | Should -Contain "Skipping package hash validation as feature 'usePackageHashValidation' is not enabled." -Because $Output.String + } + } + + Context "Installing a Package (Happy Path) with hash validation enabled" { + BeforeAll { + Restore-ChocolateyInstallSnapshot + + $null = Enable-ChocolateyFeature -Name "usePackageHashValidation" + + $PackageUnderTest = "installpackage" + + $Output = Invoke-Choco install $PackageUnderTest --debug --confirm } It "Exits with Success (0)" { @@ -141,6 +213,14 @@ It "Outputs a message showing that installation was successful" { $Output.String | Should -Match "Chocolatey installed 1/1 packages\." } + + It "Should mention that package hash verification was skipped since local folder source is being used" { + if ((Test-HasNuGetV3Source) -or (-not $env:TEST_KITCHEN)) { + $Output.Lines | Should -Contain "Source does not provide a package hash, skipping package hash validation." -Because $Output.String + } else { + $Output.Lines | Should -Contain "Package hash matches expected hash." -Because $Output.String + } + } } Context "Installing a Package (Happy Path) including configured sources" { From a46f1df0a1699aa727b1e8a16eaf28cfaff065cb Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Fri, 24 May 2024 02:20:52 -0700 Subject: [PATCH 25/37] (#3381) Add Pester tests for rule command The next release includes a new choco rule command, that allows displaying information about the validation rules that are currently in use by Chocolatey CLI. This commit adds basic Pester tests for exercising this command, along with its subcommands. --- .../commands/choco-rule.Tests.ps1 | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 tests/pester-tests/commands/choco-rule.Tests.ps1 diff --git a/tests/pester-tests/commands/choco-rule.Tests.ps1 b/tests/pester-tests/commands/choco-rule.Tests.ps1 new file mode 100644 index 0000000000..b2fc482eb9 --- /dev/null +++ b/tests/pester-tests/commands/choco-rule.Tests.ps1 @@ -0,0 +1,92 @@ +Import-Module helpers/common-helpers + +Describe "choco rule" -Tag Chocolatey, RuleCommand { + BeforeDiscovery { + } + + BeforeAll { + Remove-NuGetPaths + Initialize-ChocolateyTestInstall + + New-ChocolateyInstallSnapshot + } + + AfterAll { + Remove-ChocolateyTestInstall + } + + Context "Running without subcommand specified" { + BeforeAll { + Restore-ChocolateyInstallSnapshot + + $Output = Invoke-Choco rule + } + + It "Exits with Success (0)" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Displays the rules expected" { + $Output.Lines | Should -Contain 'CHCR0001: A required element is missing or has no content in the package nuspec file.' -Because $Output.String + $Output.Lines | Should -Contain 'CHCR0002: Enabling license acceptance requires a license url.' -Because $Output.String + $Output.Lines | Should -Contain 'CHCU0001: The specified content of the element is not of the expected type and can not be accepted.' -Because $Output.String + $Output.Lines | Should -Contain 'CHCU0002: Unsupported element is used.' -Because $Output.String + } + } + + Context "Running with list subcommand" { + BeforeAll { + Restore-ChocolateyInstallSnapshot + + $Output = Invoke-Choco rule list + } + + It "Exits with Success (0)" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Displays the rules expected" { + $Output.Lines | Should -Contain 'CHCR0001: A required element is missing or has no content in the package nuspec file.' -Because $Output.String + $Output.Lines | Should -Contain 'CHCR0002: Enabling license acceptance requires a license url.' -Because $Output.String + $Output.Lines | Should -Contain 'CHCU0001: The specified content of the element is not of the expected type and can not be accepted.' -Because $Output.String + $Output.Lines | Should -Contain 'CHCU0002: Unsupported element is used.' -Because $Output.String + } + } + + Context "Running with get subcommand specified with no additional parameters" { + BeforeAll { + Restore-ChocolateyInstallSnapshot + + $Output = Invoke-Choco rule get + } + + It "Exits with Failure (1)" { + $Output.ExitCode | Should -Be 1 -Because $Output.String + } + + It "Displays error with correct format" { + $Output.Lines | Should -Contain "A Rule Name (-n|--name) is required when getting information for a specific rule." -Because $Output.String + } + } + + Context "Running with get subcommand specified with --name parameter" { + BeforeAll { + Restore-ChocolateyInstallSnapshot + + $Output = Invoke-Choco rule get --name CHCU0001 + } + + It "Exits with Success (0)" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Displays rule information" { + $Output.Lines | Should -Contain "Name: CHCU0001 | Severity: Error" -Because $Output.String + $Output.Lines | Should -Contain "Summary: The specified content of the element is not of the expected type and can not be accepted." -Because $Output.String + $Output.Lines | Should -Contain "Help URL:" -Because $Output.String + } + } + + # This needs to be the last test in this block, to ensure NuGet configurations aren't being created. + Test-NuGetPaths +} \ No newline at end of file From a3aeacaf071792a2e965d2d6ed4289cf5330061b Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Fri, 24 May 2024 03:00:08 -0700 Subject: [PATCH 26/37] (#2050) Add Pester test for --ignore-pinned option With the next release of Chocolatey CLI, it is possible to run choco upgrade --ignore-pinned, rather than first having to run a choco pin remove command. This commit adds a Pester test to cover the usage of the --ignore-pinned option on the upgrade command. This tests relies on correct execution of the --pin option on the install command, but this is tested elsewhere. --- .../commands/choco-upgrade.Tests.ps1 | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/pester-tests/commands/choco-upgrade.Tests.ps1 b/tests/pester-tests/commands/choco-upgrade.Tests.ps1 index 1dc59ffa7d..b0f0e178fd 100644 --- a/tests/pester-tests/commands/choco-upgrade.Tests.ps1 +++ b/tests/pester-tests/commands/choco-upgrade.Tests.ps1 @@ -11,6 +11,36 @@ Remove-ChocolateyTestInstall } + Context "Upgrade pinned package using () option" -ForEach @( + @{ Command = '--ignore-pinned' ; Contains = $true } + @{ Command = '' ; Contains = $false } + ) { + BeforeAll { + Restore-ChocolateyInstallSnapshot + + $Package = 'upgradepackage' + + # This test relies on the correct usage of the --pin option on the install + # command, but this is tested elsewhere + $null = Invoke-Choco install $Package --pin --version 1.0.0 --confirm + $null = Invoke-Choco upgrade $Package $Command --confirm + $Output = Invoke-Choco pin list + } + + It "Exits with Success (0)" { + $Output.ExitCode | Should -Be 0 -Because $Output.String + } + + It "Output should include upgraded package, with new pin in place" { + if ($Contains) { + $Output.String | Should -Match "$Package|1.1.0" + } + else { + $Output.String | Should -Match "$Package|1.0.0" + } + } + } + Context "Upgrade package with () specified" -ForEach @( @{ Command = '--pin' ; Contains = $true } @{ Command = '' ; Contains = $false } From 12455116b3d247d00bcb5f38ba310ef0b1e4e263 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Mon, 27 May 2024 07:52:27 -0700 Subject: [PATCH 27/37] (tests) Working on tests during pairing session Attempting to fix Pester tests on Test-Kitchen during pairing session with Cory. --- tests/pester-tests/commands/choco-info.Tests.ps1 | 4 +++- tests/pester-tests/commands/choco-upgrade.Tests.ps1 | 4 ++-- .../powershell-commands/Get-EnvironmentVariable.Tests.ps1 | 8 +++++--- .../powershell-commands/Install-ChocolateyPath.Tests.ps1 | 6 +++++- .../powershell-commands/Set-EnvironmentVariable.Tests.ps1 | 7 +++---- .../Uninstall-ChocolateyPath.Tests.ps1 | 2 +- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/tests/pester-tests/commands/choco-info.Tests.ps1 b/tests/pester-tests/commands/choco-info.Tests.ps1 index d727aa461c..6fc502de57 100644 --- a/tests/pester-tests/commands/choco-info.Tests.ps1 +++ b/tests/pester-tests/commands/choco-info.Tests.ps1 @@ -16,7 +16,9 @@ BeforeAll { Remove-NuGetPaths Initialize-ChocolateyTestInstall -Source $PSScriptRoot\testpackages - Invoke-Choco install installpackage --package-parameters="bob" --user="bill" --password="secure-password" --confirm + + $Setup = Invoke-Choco install installpackage --package-parameters="bob" --user="bill" --password="secure-password" --confirm + $Setup.ExitCode | Should -Be 0 -Because $Setup.String $Output = Invoke-Choco info installpackage --local-only } diff --git a/tests/pester-tests/commands/choco-upgrade.Tests.ps1 b/tests/pester-tests/commands/choco-upgrade.Tests.ps1 index b0f0e178fd..c0f876b07d 100644 --- a/tests/pester-tests/commands/choco-upgrade.Tests.ps1 +++ b/tests/pester-tests/commands/choco-upgrade.Tests.ps1 @@ -173,7 +173,7 @@ } It 'Displays that upgrade was attempted but wasnt required' { - $Output.Lines | Should -Contain "Chocolatey upgraded 0/2 packages." -Because $Output.String + $Output.String | Should -MatchExactly "Chocolatey upgraded 0" } Context "when using enhanced exit codes" { @@ -188,7 +188,7 @@ } It 'Displays that upgrade was attempted but wasnt required' { - $Output.Lines | Should -Contain "Chocolatey upgraded 0/2 packages." -Because $Output.String + $Output.String | Should -MatchExactly "Chocolatey upgraded 0" } } } diff --git a/tests/pester-tests/powershell-commands/Get-EnvironmentVariable.Tests.ps1 b/tests/pester-tests/powershell-commands/Get-EnvironmentVariable.Tests.ps1 index d0bf326a46..f145b26261 100644 --- a/tests/pester-tests/powershell-commands/Get-EnvironmentVariable.Tests.ps1 +++ b/tests/pester-tests/powershell-commands/Get-EnvironmentVariable.Tests.ps1 @@ -21,9 +21,11 @@ Describe 'Get-EnvironmentVariable helper function tests' -Tags Cmdlets { } } - Context 'Can retrieve the PATH variable without expanding environment names for the scope' { - It 'Retrieves the PATH value with un-expanded environment names' { - Get-EnvironmentVariable -Name 'PATH' -Scope 'Machine' | Should -Match '%[^%;\]+%' + Context 'Can retrieve the PATH variable without expanding environment names for the Machine scope' { + It 'Retrieves the Machine PATH value with un-expanded environment names' { + # We expect there to be an entry similar to the following: "%SystemRoot%\system32", since this + # is there by default in a Windows install + Get-EnvironmentVariable -Name 'PATH' -Scope 'Machine' | Should -Match '%[^%;\\]+%' } } } \ No newline at end of file diff --git a/tests/pester-tests/powershell-commands/Install-ChocolateyPath.Tests.ps1 b/tests/pester-tests/powershell-commands/Install-ChocolateyPath.Tests.ps1 index 81706033bf..379a73db76 100644 --- a/tests/pester-tests/powershell-commands/Install-ChocolateyPath.Tests.ps1 +++ b/tests/pester-tests/powershell-commands/Install-ChocolateyPath.Tests.ps1 @@ -16,9 +16,13 @@ @{ Scope = 'Machine' } ) { Context 'Path "<_>"' -ForEach @("C:\test", "C:\tools") { + AfterEach { + Uninstall-ChocolateyPath -Path $_ -Scope $Scope + } + It 'stores the value in the desired PATH scope' { Install-ChocolateyPath -Path $_ -Scope $Scope - [Environment]::GetEnvironmentVariable('PATH', $_, $Scope) -split [IO.Path]::PathSeparator | Should -Contain $_ + [Environment]::GetEnvironmentVariable('PATH', $Scope) -split [IO.Path]::PathSeparator | Should -Contain $_ } } } diff --git a/tests/pester-tests/powershell-commands/Set-EnvironmentVariable.Tests.ps1 b/tests/pester-tests/powershell-commands/Set-EnvironmentVariable.Tests.ps1 index 6b5cc580cd..5b1a9bc840 100644 --- a/tests/pester-tests/powershell-commands/Set-EnvironmentVariable.Tests.ps1 +++ b/tests/pester-tests/powershell-commands/Set-EnvironmentVariable.Tests.ps1 @@ -6,7 +6,7 @@ Describe 'Set-EnvironmentVariable helper function tests' -Tags Cmdlets { Import-Module "$testLocation\helpers\chocolateyInstaller.psm1" } - Context 'Sets an environment variable value at the target scope' -ForEach @( + Context 'Sets an environment variable value at the target ' -ForEach @( @{ Scope = 'Process' } @{ Scope = 'User' } @{ Scope = 'Machine' } @@ -24,9 +24,8 @@ Describe 'Set-EnvironmentVariable helper function tests' -Tags Cmdlets { Set-EnvironmentVariable -Name $Name -Value $Value -Scope $Scope [Environment]::GetEnvironmentVariable($Name, $Scope) | Should -BeExactly $Value - if ($Scope -ne 'Process') { - [Environment]::GetEnvironmentVariable($Name) | Should -BeExactly $Value - } + # We are explicitly checking the Process variable here. + [Environment]::GetEnvironmentVariable($Name, 'Process') | Should -BeExactly $Value } AfterAll { diff --git a/tests/pester-tests/powershell-commands/Uninstall-ChocolateyPath.Tests.ps1 b/tests/pester-tests/powershell-commands/Uninstall-ChocolateyPath.Tests.ps1 index 6d15ff28c1..29dbeec65b 100644 --- a/tests/pester-tests/powershell-commands/Uninstall-ChocolateyPath.Tests.ps1 +++ b/tests/pester-tests/powershell-commands/Uninstall-ChocolateyPath.Tests.ps1 @@ -18,7 +18,7 @@ It 'removes a stored PATH value in the desired PATH scope' { Uninstall-ChocolateyPath -Path $_ -Scope $Scope - [Environment]::GetEnvironmentVariable('PATH', $_, $Scope) -split [IO.Path]::PathSeparator | Should -Not -Contain $_ + [Environment]::GetEnvironmentVariable('PATH', $Scope) -split [IO.Path]::PathSeparator | Should -Not -Contain $_ } } } From 71df5cc2e385322f0ac7a1e973062d2cbb925250 Mon Sep 17 00:00:00 2001 From: Rain Sallow Date: Tue, 28 May 2024 16:07:40 -0400 Subject: [PATCH 28/37] (#310) Fixup v2 compatibility Previous changes for this issue had issues loading in powershell v2, this fixes those to the extent it's possible to do so. --- .../chocolatey/tools/chocolateysetup.psm1 | 2 +- .../helpers/chocolateyInstaller.psm1 | 39 +++++++++++-------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/nuspec/chocolatey/chocolatey/tools/chocolateysetup.psm1 b/nuspec/chocolatey/chocolatey/tools/chocolateysetup.psm1 index 76ad358090..9357467eb3 100644 --- a/nuspec/chocolatey/chocolatey/tools/chocolateysetup.psm1 +++ b/nuspec/chocolatey/chocolatey/tools/chocolateysetup.psm1 @@ -858,7 +858,7 @@ function Invoke-Chocolatey-Initial { try { $chocoInstallationFolder = Get-ChocolateyInstallFolder $chocoExe = Join-Path -Path $chocoInstallationFolder -ChildPath "choco.exe" - $runResult = & $chocoExe -v *>&1 + $runResult = & $chocoExe -v 2>&1 if ($LASTEXITCODE -eq 0) { Write-Debug "Chocolatey CLI execution completed successfully." } diff --git a/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 b/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 index dfa78d18c6..86e3d52e08 100644 --- a/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 +++ b/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 @@ -153,26 +153,31 @@ if (Test-Path $extensionsPath) { # In effect we ensure that any command calls that match the name of one of our commands # will resolve to _our_ commands (preferring licensed cmdlets in the case of a name collision), # preventing packages from overriding them with their own commands and potentially breaking things. -$ExecutionContext.InvokeCommand.PreCommandLookupAction = { - param($command, $eventArgs) +# +# This functionality is only available in v3 and later, so using this in v2 will not +# work; check for the property before trying to set it. +if ($ExecutionContext.InvokeCommand.PreCommandLookupAction) { + $ExecutionContext.InvokeCommand.PreCommandLookupAction = { + param($command, $eventArgs) - # Don't run this handler for stuff PowerShell is looking up internally - if ($eventArgs.CommandOrigin -eq 'Runspace') { - $resolvedCommand = if ($command -in $chocolateyCmdlets.Licensed) { - Get-Command "$command*" -Module 'chocolatey.licensed' -CommandType Cmdlet -ErrorAction Ignore | - Where-Object { $_.Name -match "^$command(Cmdlet)?$" } | - Select-Object -First 1 - } - elseif ($command -in $chocolateyCmdlets.Default) { - Get-Command $command -Module "Chocolatey.PowerShell" -CommandType Cmdlet -ErrorAction Ignore - } + # Don't run this handler for stuff PowerShell is looking up internally + if ($eventArgs.CommandOrigin -eq 'Runspace') { + $resolvedCommand = if ($chocolateyCmdlets.Licensed -contains $command) { + Get-Command "$command*" -Module 'chocolatey.licensed' -CommandType Cmdlet -ErrorAction SilentlyContinue | + Where-Object { @($command, "$($command)Cmdlet") -contains $_.Name } | + Select-Object -First 1 + } + elseif ($chocolateyCmdlets.Default -contains $command) { + Get-Command $command -Module "Chocolatey.PowerShell" -CommandType Cmdlet -ErrorAction SilentlyContinue + } - if ($resolvedCommand) { - $eventArgs.Command = $resolvedCommand - $eventArgs.StopSearch = $true + if ($resolvedCommand) { + $eventArgs.Command = $resolvedCommand + $eventArgs.StopSearch = $true + } } - } -}.GetNewClosure() + }.GetNewClosure() +} # todo: explore removing this for a future version Export-ModuleMember -Function * -Alias * -Cmdlet * From dfc2b921b7c796fc0d70ca1ddba94113ca0194cb Mon Sep 17 00:00:00 2001 From: Rain Sallow Date: Tue, 28 May 2024 16:11:50 -0400 Subject: [PATCH 29/37] (#310) Fix test issues Fix up Set-EnvironmentVariable and Update-SessionEnvironment tests. --- .../Get-EnvironmentVariable.Tests.ps1 | 10 +++++++++- .../Set-EnvironmentVariable.Tests.ps1 | 14 +++++++++----- .../Update-SessionEnvironment.Tests.ps1 | 3 ++- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/tests/pester-tests/powershell-commands/Get-EnvironmentVariable.Tests.ps1 b/tests/pester-tests/powershell-commands/Get-EnvironmentVariable.Tests.ps1 index f145b26261..0e6c58f98f 100644 --- a/tests/pester-tests/powershell-commands/Get-EnvironmentVariable.Tests.ps1 +++ b/tests/pester-tests/powershell-commands/Get-EnvironmentVariable.Tests.ps1 @@ -22,10 +22,18 @@ Describe 'Get-EnvironmentVariable helper function tests' -Tags Cmdlets { } Context 'Can retrieve the PATH variable without expanding environment names for the Machine scope' { + BeforeAll { + Install-ChocolateyPath -Path "%systemroot%\test" -PathType Machine + } + + AfterAll { + Uninstall-ChocolateyPath -Path "%systemroot%\test" -PathType Machine + } + It 'Retrieves the Machine PATH value with un-expanded environment names' { # We expect there to be an entry similar to the following: "%SystemRoot%\system32", since this # is there by default in a Windows install - Get-EnvironmentVariable -Name 'PATH' -Scope 'Machine' | Should -Match '%[^%;\\]+%' + Get-EnvironmentVariable -Name 'PATH' -Scope 'Machine' -PreserveVariables | Should -Match '%systemroot%\\test' } } } \ No newline at end of file diff --git a/tests/pester-tests/powershell-commands/Set-EnvironmentVariable.Tests.ps1 b/tests/pester-tests/powershell-commands/Set-EnvironmentVariable.Tests.ps1 index 5b1a9bc840..7e67ca9e2a 100644 --- a/tests/pester-tests/powershell-commands/Set-EnvironmentVariable.Tests.ps1 +++ b/tests/pester-tests/powershell-commands/Set-EnvironmentVariable.Tests.ps1 @@ -20,17 +20,21 @@ Describe 'Set-EnvironmentVariable helper function tests' -Tags Cmdlets { } Describe 'Setting environment variable ' -ForEach $variables { - It 'Sets the target environment variable in the proper scope, as well as current process scope' { + BeforeAll { Set-EnvironmentVariable -Name $Name -Value $Value -Scope $Scope - [Environment]::GetEnvironmentVariable($Name, $Scope) | Should -BeExactly $Value - - # We are explicitly checking the Process variable here. - [Environment]::GetEnvironmentVariable($Name, 'Process') | Should -BeExactly $Value } AfterAll { Set-EnvironmentVariable -Name $Name -Value "" -Scope $Scope } + + It 'sets the target environment variable in the proper scope' { + [Environment]::GetEnvironmentVariable($Name, $Scope) | Should -BeExactly $Value + } + + It 'propagates the change to the current process' { + Get-Content "Env:\$Name" | Should -BeExactly $Value + } } } } \ No newline at end of file diff --git a/tests/pester-tests/powershell-commands/Update-SessionEnvironment.Tests.ps1 b/tests/pester-tests/powershell-commands/Update-SessionEnvironment.Tests.ps1 index 742bc3da5f..9f8bcccbc6 100644 --- a/tests/pester-tests/powershell-commands/Update-SessionEnvironment.Tests.ps1 +++ b/tests/pester-tests/powershell-commands/Update-SessionEnvironment.Tests.ps1 @@ -17,12 +17,13 @@ Update-SessionEnvironment $env:Test | Should -BeExactly 'user-value' $env:Test2 | Should -BeExactly 'machine-value' - $env:Test3 | Should -BeNullOrEmpty -Because 'Process-only values should not be preserved' + $env:Test3 | Should -BeExactly 'process-value' } AfterAll { [Environment]::SetEnvironmentVariable("Test", [string]::Empty, "User") [Environment]::SetEnvironmentVariable("Test2", [string]::Empty, "Machine") + $env:Test3 = '' } } } \ No newline at end of file From 62f07084494cab1f4f336983afde386e9d4e722f Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Wed, 29 May 2024 16:38:29 -0700 Subject: [PATCH 30/37] (tests) Remove v2 import tests PowerShell V2 is no longer supported. With the change to compiled cmdlets, these will not work on any system that doesn't have PowerShell v3 or newer due to the .Net Framework used. This removes the tests as they will be unable to load the compiled cmdlets and fail the tests. --- tests/pester-tests/chocolatey.Tests.ps1 | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/tests/pester-tests/chocolatey.Tests.ps1 b/tests/pester-tests/chocolatey.Tests.ps1 index 2227c120e8..ea441658ac 100644 --- a/tests/pester-tests/chocolatey.Tests.ps1 +++ b/tests/pester-tests/chocolatey.Tests.ps1 @@ -195,20 +195,6 @@ Describe "Ensuring Chocolatey is correctly installed" -Tag Environment, Chocolat # $null = Invoke-Choco install MicrosoftWindowsPowerShellV2 -s windowsfeatures } - # This is Foss only as PowerShell running under version 2 doesn't have .net available and can't import the Licensed DLL. - # Tests on Windows 7 show no issues with running Chocolatey under Windows 7 with PowerShell v2 aside from issues surrounding TLS versions that we cannot resolve without an upgrade to Windows 7. - It "Imports ChocolateyInstaller module successfully in PowerShell v2" -Tag FossOnly { - $command = 'try { $ErrorActionPreference = ''Stop''; Import-Module $env:ChocolateyInstall\helpers\chocolateyInstaller.psm1 } catch { $_ ; exit 1 }' - $result = & powershell.exe -Version 2 -noprofile -command $command - $LastExitCode | Should -BeExactly 0 -Because $result - } - - It "Imports ChocolateyProfile module successfully in PowerShell v2" { - $command = 'try { $ErrorActionPreference = ''Stop''; Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 } catch { $_ ; exit 1 }' - $result = & powershell.exe -Version 2 -noprofile -command $command - $LastExitCode | Should -BeExactly 0 -Because $result - } - Context "chocolateyScriptRunner.ps1" { BeforeAll { $Command = @' From 13f690362da48ee502d19a30a06501f456e0d367 Mon Sep 17 00:00:00 2001 From: Rain Sallow Date: Wed, 29 May 2024 17:09:41 -0400 Subject: [PATCH 31/37] (#310) Set-EnvironmentVariable: delete values properly We noticed over the last few days that the previous version of this code was *adding* blank values into the registry, which caused some issues with how environment variables are applied to new processes. Specifically, if a Machine-level variable is set, and a User-level variable by the same name is set to a blank value, new processes do not properly inherit the Machine-level value and it remains blank/unset. This change ensures that if someone sets an environment variable to a blank value, it will be properly *deleted* rather than set to a blank value. Additionally, a minor change has been made to Update-SessionEnvironment to ensure that if there are somehow blank values in the registry, it can sidestep those issues if it is called. --- .../Helpers/EnvironmentHelper.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Chocolatey.PowerShell/Helpers/EnvironmentHelper.cs b/src/Chocolatey.PowerShell/Helpers/EnvironmentHelper.cs index 468c7bb3b7..fedc3d86e2 100644 --- a/src/Chocolatey.PowerShell/Helpers/EnvironmentHelper.cs +++ b/src/Chocolatey.PowerShell/Helpers/EnvironmentHelper.cs @@ -166,7 +166,14 @@ public static void SetVariable(PSCmdlet cmdlet, string name, EnvironmentVariable cmdlet.WriteDebug($"Registry type for {name} is/will be {registryType}"); - registryKey.SetValue(name, value, registryType); + if (string.IsNullOrEmpty(value)) + { + registryKey.DeleteValue(name, throwOnMissingValue: false); + } + else + { + registryKey.SetValue(name, value, registryType); + } } try @@ -219,7 +226,10 @@ public static void UpdateSession(PSCmdlet cmdlet) foreach (var name in GetVariableNames(scope)) { var value = GetVariable(cmdlet, name, scope); - SetVariable(cmdlet, name, EnvironmentVariableTarget.Process, value); + if (!string.IsNullOrEmpty(value)) + { + SetVariable(cmdlet, name, EnvironmentVariableTarget.Process, value); + } } } From 0d7da1a13f49327ed1ee651174bda585cef242b3 Mon Sep 17 00:00:00 2001 From: Cory Knox <30301021+corbob@users.noreply.github.com> Date: Thu, 30 May 2024 10:53:12 -0700 Subject: [PATCH 32/37] (tests) Some minor tweaks for test consistency --- tests/pester-tests/commands/choco-info.Tests.ps1 | 5 ++--- tests/pester-tests/commands/choco-source.Tests.ps1 | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/pester-tests/commands/choco-info.Tests.ps1 b/tests/pester-tests/commands/choco-info.Tests.ps1 index 6fc502de57..60c7b40747 100644 --- a/tests/pester-tests/commands/choco-info.Tests.ps1 +++ b/tests/pester-tests/commands/choco-info.Tests.ps1 @@ -14,10 +14,10 @@ Context "Should include remembered arguments (including redacted) when using option --local-only" { BeforeAll { - Remove-NuGetPaths Initialize-ChocolateyTestInstall -Source $PSScriptRoot\testpackages - $Setup = Invoke-Choco install installpackage --package-parameters="bob" --user="bill" --password="secure-password" --confirm + $Setup = Invoke-Choco install installpackage --package-parameters="bob" --password="secure-password" --confirm + $Setup.ExitCode | Should -Be 0 -Because $Setup.String $Output = Invoke-Choco info installpackage --local-only @@ -36,7 +36,6 @@ Context "Should include configured sources" { BeforeAll { - Remove-NuGetPaths Initialize-ChocolateyTestInstall -Source $PSScriptRoot\testpackages Invoke-Choco install installpackage --confirm diff --git a/tests/pester-tests/commands/choco-source.Tests.ps1 b/tests/pester-tests/commands/choco-source.Tests.ps1 index 2c9035662c..36ae2a9866 100644 --- a/tests/pester-tests/commands/choco-source.Tests.ps1 +++ b/tests/pester-tests/commands/choco-source.Tests.ps1 @@ -566,6 +566,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SourceCommand { # Ensure source is enable Invoke-Choco $CurrentCommand add --name "already-enabled" --source "https://somewhere/out/there/" + Invoke-Choco $CurrentCommand enable --name "already-enabled" $Output = Invoke-Choco $CurrentCommand enable --name "already-enabled" } From 2fd00fa1cb9081221519ecb686336461eac2f5e0 Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Thu, 30 May 2024 13:07:28 -0700 Subject: [PATCH 33/37] (maint) Update Authenticode Signature In the previous commit, the PowerShell file was updated, and a new signature is required. --- .../chocolatey/tools/chocolateysetup.psm1 | 50 +++++++++---------- .../helpers/chocolateyInstaller.psm1 | 50 +++++++++---------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/nuspec/chocolatey/chocolatey/tools/chocolateysetup.psm1 b/nuspec/chocolatey/chocolatey/tools/chocolateysetup.psm1 index 9357467eb3..0034cbe82f 100644 --- a/nuspec/chocolatey/chocolatey/tools/chocolateysetup.psm1 +++ b/nuspec/chocolatey/chocolatey/tools/chocolateysetup.psm1 @@ -876,8 +876,8 @@ Export-ModuleMember -Function Initialize-Chocolatey # SIG # Begin signature block # MIInKwYJKoZIhvcNAQcCoIInHDCCJxgCAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG -# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCC8Wmtrs9N0S3FW -# cp2ebCXvAwP1tJVxI2dlqSwsrccSpKCCIK4wggWNMIIEdaADAgECAhAOmxiO+dAt +# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCArPR/MaAFOnPhm +# wTraOHhBiut3LMThkjxzi7DsT2up/qCCIK4wggWNMIIEdaADAgECAhAOmxiO+dAt # 5+/bUOIIQBhaMA0GCSqGSIb3DQEBDAUAMGUxCzAJBgNVBAYTAlVTMRUwEwYDVQQK # EwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xJDAiBgNV # BAMTG0RpZ2lDZXJ0IEFzc3VyZWQgSUQgUm9vdCBDQTAeFw0yMjA4MDEwMDAwMDBa @@ -1057,30 +1057,30 @@ Export-ModuleMember -Function Initialize-Chocolatey # IFNIQTM4NCAyMDIxIENBMQIQBNI793flHTneCMtwLiiYFTANBglghkgBZQMEAgEF # AKCBhDAYBgorBgEEAYI3AgEMMQowCKACgAChAoAAMBkGCSqGSIb3DQEJAzEMBgor # BgEEAYI3AgEEMBwGCisGAQQBgjcCAQsxDjAMBgorBgEEAYI3AgEVMC8GCSqGSIb3 -# DQEJBDEiBCDMHmRGjDIKOEla+IaM/zMWLkvV/rMxHg45my3wmHLVfDANBgkqhkiG -# 9w0BAQEFAASCAYB3TE6Lis+z/D5XQ11XK2+4We7m53DgAY7C0+CWG/yiJ7ImRdNF -# iJQV4TXHtT1fT3ke/ZXkZE95r+W6KPg1bsm8SBBEPm/8n4lgfcP00uw/rAcejuXD -# bVXrlrygICzuG+iocYgGcLL1+UxMr5mnNIye4mLMQkrluPSXf6+3jPZrIMCS8d7G -# V6zHEyiK1BVqfl0708/LHFQ3aPwI5z9xIZqTZFDjnDgFw5z2D1bq+wZY/tB04v1F -# pLIDxgLI7l++TJZS5yjxJP54W2ysevYamY6lj6pS+3x7DMohf4yiZ/v/gOAZxFiT -# ir0rkdzIjWc/wIdGaGg+AvQPisOvndFLUp3BzsmOqjC1QyA1zv7F4QD99FAw6QVb -# vl+zF9z8XahH5uYGoe/cZiVjO1W+it5/MhB/eyXUL6vV95pUjD/mackEDBOPHD85 -# bvd2Z695m+l47/7W9lDw2OFeRIxIDn8p2e/7MC3u2DeUy7wKjLy430SOzgVPYvzj -# fiuYyp2COsJOTumhggMgMIIDHAYJKoZIhvcNAQkGMYIDDTCCAwkCAQEwdzBjMQsw +# DQEJBDEiBCDGe5bdr9fhZlgcmD0adH88bZKumDvnmMPc9syGf+0gjTANBgkqhkiG +# 9w0BAQEFAASCAYA+7vMPYKMLM9YYgi74s1I/0mfFEOTHAZ1q8M7PQNczDxMBd6nT +# QLlImypyhnYyAmyq1pqheD+zfRS0JAkrzFAqjxefGQka/Jvwe1/vyTOy61pUoHWD +# MvUTswW+VPLjuk2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meuarZIUEl7BSthP4N5KF/BNQbpetVgWRCFuZJ3 +# fSO9qrmQCtGm6S7ldYUgChUR2pHU+N3y1kPhmsr2bu/WDtIFojZxrickwHajrX83 +# 24axIasm3XjdMUWmhZLAZo48QN1c8hUwtiwTLo+8ZGUwmjbLEp4v7WDBI/ZcD0WW +# 67XftIHKVDi4gJJyR9uKQdFrmIIqOHeJbgffxhwuEIlDQ3X45Umw+rymBiKOGxA= # SIG # End signature block diff --git a/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 b/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 index 86e3d52e08..d71dfe2ed1 100644 --- a/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 +++ b/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 @@ -185,8 +185,8 @@ Export-ModuleMember -Function * -Alias * -Cmdlet * # SIG # Begin signature block # MIInKwYJKoZIhvcNAQcCoIInHDCCJxgCAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG -# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBdE9z66tk0Iy2q -# ReXBHFIMtqEDnptfyMNaqW2C2KXeYKCCIK4wggWNMIIEdaADAgECAhAOmxiO+dAt +# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCDNL/wxXxTwoao9 +# +niutFOSQWJKM7QvRr2vKMT3E6T+AKCCIK4wggWNMIIEdaADAgECAhAOmxiO+dAt # 5+/bUOIIQBhaMA0GCSqGSIb3DQEBDAUAMGUxCzAJBgNVBAYTAlVTMRUwEwYDVQQK # EwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xJDAiBgNV # BAMTG0RpZ2lDZXJ0IEFzc3VyZWQgSUQgUm9vdCBDQTAeFw0yMjA4MDEwMDAwMDBa @@ -366,30 +366,30 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JvOJY3SbEcSK1DsI91n2FF3vYotCZaGfuicbxhcvpIMdqtzbxiKIIsUda +# 1oUOmQr2+3ehuGKftW+EGk83ZKObNF98RMSA/4YFO9e42FtB7P9+FSbJ1mXRUnFC +# sftewOZA7haYCPiZV6Tt/kBJaG9Y2ROrq4rDrbMmKWl3WOWui/tyEwm12GcNLgpc +# cRY1FUXMfOL1kM9fgLlUCKORaN9sB1kEKOGXGFGkpKyWQNGlpQn/EuKKqHEhwl4= # SIG # End signature block From c74a19cdcf20942d3fda5383d821a78c1d6c6a4a Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Fri, 31 May 2024 09:02:40 -0700 Subject: [PATCH 34/37] (#1901) Revert commit to display location Based on some testing that was completed, we can't bring in this change currently, since we can't provide the same functionality in CLE without bumping the version number of the CLI dependency in the nuspec file. This is not something that we are ready to do, so taking out this change, and the issue will be moved to the next milestone. --- src/chocolatey/infrastructure.app/services/NugetService.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index f742d93dc2..c1e3dc6061 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -196,7 +196,6 @@ it is possible that incomplete package lists are returned from a command ChocolateyPackageMetadata packageLocalMetadata; string packageInstallLocation = null; - string deploymentLocation = null; if (package.PackagePath != null && !string.IsNullOrWhiteSpace(package.PackagePath)) { packageLocalMetadata = new ChocolateyPackageMetadata(package.PackagePath, _fileSystem); @@ -218,7 +217,6 @@ it is possible that incomplete package lists are returned from a command } } - deploymentLocation = packageInfo.DeploymentLocation; if (!string.IsNullOrWhiteSpace(packageInfo.Arguments)) { var decryptedArguments = ArgumentsUtility.DecryptPackageArgumentsFile(_fileSystem, packageInfo.Package.Id, packageInfo.Package.Version.ToNormalizedStringChecked()); @@ -251,7 +249,7 @@ Package url{6} Tags: {9} Software Site: {10} Software License: {11}{12}{13}{14}{15}{16} - Description: {17}{18}{19}{20} + Description: {17}{18}{19} ".FormatWith( package.Title.EscapeCurlyBraces(), package.Published.GetValueOrDefault().UtcDateTime.ToShortDateString(), @@ -286,7 +284,6 @@ Package url{6} package.Summary != null && !string.IsNullOrWhiteSpace(package.Summary.ToStringSafe()) ? "\r\n Summary: {0}".FormatWith(package.Summary.EscapeCurlyBraces().ToStringSafe()) : string.Empty, package.Description.EscapeCurlyBraces().Replace("\n ", "\n").Replace("\n", "\n "), !string.IsNullOrWhiteSpace(package.ReleaseNotes.ToStringSafe()) ? "{0} Release Notes: {1}".FormatWith(Environment.NewLine, package.ReleaseNotes.EscapeCurlyBraces().Replace("\n ", "\n").Replace("\n", "\n ")) : string.Empty, - !string.IsNullOrWhiteSpace(deploymentLocation) ? "{0} Deployed to: '{1}'".FormatWith(Environment.NewLine, deploymentLocation) : string.Empty, packageArgumentsUnencrypted != null ? packageArgumentsUnencrypted : string.Empty )); } From 80f86d506e6ccedf9b519d9ecba054f041364e99 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Tue, 4 Jun 2024 08:17:09 -0700 Subject: [PATCH 35/37] (#23) Move call to SetRemotePackageNamesIfAllSpecified The SetRemotePackageNamesIfAllSpecified method HAS to be called AFTER the call to GetRemoteRepositories. In that method, the Sources on the configuration object are expanded to be the full source URL's, rather than the named sources from the chocolatey.config file, i.e. https://community.chocolatey.org/api/v2/ rather than simply "chocolatey". This is important, since the full URL is what is used to ensure that a "choco install all" is not being attempted against one of the configured public sources. This wasn't picked up during the initial PR review, but it was picked up during manual testing, and this commit is the output of that manual testing. --- .../infrastructure.app/services/NugetService.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index c1e3dc6061..15cbbe8c6a 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -510,8 +510,6 @@ public virtual ConcurrentDictionary Install(ChocolateyCon _fileSystem.EnsureDirectoryExists(ApplicationParameters.PackagesLocation); var packageResultsToReturn = new ConcurrentDictionary(StringComparer.InvariantCultureIgnoreCase); - SetRemotePackageNamesIfAllSpecified(config, () => { }); - NuGetVersion version = !string.IsNullOrWhiteSpace(config.Version) ? NuGetVersion.Parse(config.Version) : null; if (config.Force) { @@ -520,6 +518,14 @@ public virtual ConcurrentDictionary Install(ChocolateyCon var sourceCacheContext = new ChocolateySourceCacheContext(config); var remoteRepositories = NugetCommon.GetRemoteRepositories(config, _nugetLogger, _fileSystem); + + // The following method HAS to be called AFTER the call to GetRemoteRepositories. + // In that method, the Sources on the configuration object are expanded to be the full source URL's, rather than the named + // sources from the chocolatey.config file, i.e. https://community.chocolatey.org/api/v2/ rather than simply "chocolatey". + // This is important, since the full URL is what is used to ensure that a "choco install all" is not being attempted against + // one of the configured public sources in the following method. + SetRemotePackageNamesIfAllSpecified(config, () => { }); + var remoteEndpoints = NugetCommon.GetRepositoryResources(remoteRepositories, sourceCacheContext); var localRepositorySource = NugetCommon.GetLocalRepository(); var pathResolver = NugetCommon.GetPathResolver(_fileSystem); From 604538ff33c04dd23efed9f94718b981dcd752e8 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Wed, 5 Jun 2024 01:48:29 -0700 Subject: [PATCH 36/37] (maint) Corrected casing of file For some reason, this was lost during the merge, so correcting here prior to merge back into develop. --- gitreleasemanager.yaml | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 gitreleasemanager.yaml diff --git a/gitreleasemanager.yaml b/gitreleasemanager.yaml deleted file mode 100644 index bdbcc914cd..0000000000 --- a/gitreleasemanager.yaml +++ /dev/null @@ -1,38 +0,0 @@ -issue-labels-include: - - Breaking Change - - Deprecate - - Feature - - C4B Feature - - Bug - - Improvement - - Documentation - - Dependency Change -issue-labels-exclude: - - Internal Refactoring - - BuildAutomation - - NO RELEASE NOTES -issue-labels-alias: - - name: Documentation - header: Documentation - plural: Documentation - - name: Bug - header: Bug Fix - plural: Bug Fixes - - name: Deprecate - header: Deprecated Feature - plural: Deprecated Features -create: - include-sha-section: true - sha-section-heading: "SHA256 Hashes of the release artifacts" - sha-section-line-format: "- `{1}\t{0}`" -close: - use-issue-comments: true - issue-comment: |- - :tada: This issue has been resolved in version {milestone} :tada: - - The release is available on: - - - [GitHub Release](https://github.com/{owner}/{repository}/releases/tag/{milestone}) - - [Chocolatey Package](https://community.chocolatey.org/packages/chocolatey/{milestone}) - - Your **[GitReleaseManager](https://github.com/GitTools/GitReleaseManager)** bot :package: :rocket: From 7eb0610df1fc7f61f2deea0da4ad6fec46ce77bd Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Wed, 5 Jun 2024 04:35:29 -0700 Subject: [PATCH 37/37] (#310) Fix path to chocolatey.lib files When progressing the release of 2.3.0, it was found that the chocolatey.lib nupkg didn't contain any files. This was due to a change in the folder structure which wasn't caught during testing. This commit fixes this folder structure, pointing directly to the chocolatey.lib folder, so that running nuget pack works as expected. There may be additional changes required to this portion of the build, to make sure that everything is being created in the same way, but that can be picked up post release/ --- recipe.cake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/recipe.cake b/recipe.cake index 90b0dd3b1e..9bdbb6dc49 100644 --- a/recipe.cake +++ b/recipe.cake @@ -329,14 +329,14 @@ Task("Prepare-NuGet-Packages") .IsDependeeOf("Sign-Assemblies") .Does(() => { - CleanDirectory(BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/lib"); - EnsureDirectoryExists(BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/lib/net48"); + CleanDirectory(BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/chocolatey.lib/lib"); + EnsureDirectoryExists(BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/chocolatey.lib/lib/net48"); // Copy legal documents - CopyFile(BuildParameters.RootDirectoryPath + "/docs/legal/CREDITS.md", BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/lib/CREDITS.txt"); + CopyFile(BuildParameters.RootDirectoryPath + "/docs/legal/CREDITS.md", BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/chocolatey.lib/lib/CREDITS.txt"); - CopyFiles(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey_merged/*", BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/lib/net48"); - CopyFile(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey/chocolatey.xml", BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/lib/net48/chocolatey.xml"); + CopyFiles(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey_merged/*", BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/chocolatey.lib/lib/net48"); + CopyFile(BuildParameters.Paths.Directories.PublishedLibraries + "/chocolatey/chocolatey.xml", BuildParameters.Paths.Directories.NuGetNuspecDirectory + "/chocolatey.lib/lib/net48/chocolatey.xml"); }); Task("Prepare-MSI")