Skip to content

Commit

Permalink
Merge pull request #3063 from AdmiringWorm/new-internal-setup
Browse files Browse the repository at this point in the history
(maint) Fix test executions after internal changes
  • Loading branch information
vexx32 authored Apr 3, 2023
2 parents 3bbb5b3 + 7e59a52 commit 370e366
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
16 changes: 12 additions & 4 deletions tests/chocolatey-tests/chocolatey.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ Describe "Ensuring Chocolatey is correctly installed" -Tag Environment, Chocolat
# This is skipped when not run in CI because it modifies the local system.
Context 'License warning is worded properly' -Tag FossOnly,ListCommand,License -Skip:((-not $env:TEST_KITCHEN) -or (-not (Test-ChocolateyVersionEqualOrHigherThan '1.0.0'))) {
BeforeAll {
Restore-ChocolateyInstallSnapshot
$null = Enable-ChocolateySource 'hermes-setup'
$null = Invoke-Choco install chocolatey-license-business -y
$Output = Invoke-Choco list
}
Expand All @@ -216,10 +218,12 @@ Describe "Ensuring Chocolatey is correctly installed" -Tag Environment, Chocolat
# This is skipped when not run in CI because it modifies the local system.
Context 'PowerShell Profile comments updated correctly' -Tag ListCommand, Profile -Skip:((-not $env:TEST_KITCHEN) -or (-not (Test-ChocolateyVersionEqualOrHigherThan '1.0.0'))) {
BeforeAll {
Restore-ChocolateyInstallSnapshot
Remove-Item $Profile.CurrentUserCurrentHost -ErrorAction Ignore
New-Item $Profile.CurrentUserCurrentHost -Force
$chocolatey = (Invoke-Choco list chocolatey -r --exact).Lines | ConvertFrom-ChocolateyOutput -Command List
Enable-ChocolateySource -Name local
Enable-ChocolateySource -Name hermes-setup
$null = Invoke-Choco install chocolatey -f --version $chocolatey.Version
}

Expand All @@ -243,6 +247,7 @@ Describe "Ensuring Chocolatey is correctly installed" -Tag Environment, Chocolat
# This is skipped when not run in CI because it modifies the local system.
Context 'PowerShell Profile properly updated when Windows thinks a 5 byte file is signed' -Tag ListCommand, Profile -Skip:((-not $env:TEST_KITCHEN) -or (-not (Test-ChocolateyVersionEqualOrHigherThan '1.1.0'))) {
BeforeAll {
Restore-ChocolateyInstallSnapshot
New-Item $Profile.CurrentUserCurrentHost -Force
"" | Set-Content -Path $Profile.CurrentUserCurrentHost -Encoding UTF8
$chocolatey = (Invoke-Choco list chocolatey -r --exact).Lines | ConvertFrom-ChocolateyOutput -Command List
Expand Down Expand Up @@ -278,6 +283,7 @@ Describe "Ensuring Chocolatey is correctly installed" -Tag Environment, Chocolat
}
) {
BeforeAll {
Restore-ChocolateyInstallSnapshot
$chocolatey = (Invoke-Choco list chocolatey -r --exact).Lines | ConvertFrom-ChocolateyOutput -Command List

foreach ($shim in $RemovedShims) {
Expand All @@ -292,6 +298,7 @@ Describe "Ensuring Chocolatey is correctly installed" -Tag Environment, Chocolat
}

Enable-ChocolateySource -Name local
Enable-ChocolateySource -Name hermes-setup
$Output = Invoke-Choco install chocolatey -f --version $chocolatey.Version --no-progress
}

Expand All @@ -310,6 +317,7 @@ Describe "Ensuring Chocolatey is correctly installed" -Tag Environment, Chocolat

Context 'Ensure a corrupted config file does not cause errors' -Tag ConfigFile -Skip:(-not (Test-ChocolateyVersionEqualOrHigherThan '1.1.0')) {
BeforeAll {
Restore-ChocolateyInstallSnapshot
$ChocolateyConfigLocation = "$env:ChocolateyInstall/config/chocolatey.config"
$BadContent = "<chocolatey></chocolatey>BadFile"
# Make sure we have a chocolatey config file
Expand All @@ -333,9 +341,9 @@ Describe "Ensuring Chocolatey is correctly installed" -Tag Environment, Chocolat
'powershell'
) -Skip:((-not $env:TEST_KITCHEN) -or (-not (Test-ChocolateyVersionEqualOrHigherThan '1.1.0'))) {
BeforeAll {
New-ChocolateyInstallSnapshot
# TODO: Internalize pwsh and powershell packages...
$pwshInstall = Invoke-Choco install $_ -y -s https://community.chocolatey.org/api/v2/
Restore-ChocolateyInstallSnapshot
Enable-ChocolateySource -Name hermes-setup
$pwshInstall = Invoke-Choco install $_ -y
$ChocoUnzipped = "$(Get-TempDirectory)$(New-Guid)"
$modulePath = "$ChocoUnzipped/tools/chocolateySetup.psm1"

Expand Down Expand Up @@ -364,7 +372,7 @@ Describe "Ensuring Chocolatey is correctly installed" -Tag Environment, Chocolat
if (Test-Path $ChocoUnzipped) {
Remove-Item $ChocoUnzipped -Force -Recurse
}
$null = Invoke-Choco uninstall $_ -y -s https://community.chocolatey.org/api/v2/ --force-dependencies
$null = Invoke-Choco uninstall $_ -y --force-dependencies
Remove-ChocolateyInstallSnapshot
}

Expand Down
8 changes: 5 additions & 3 deletions tests/chocolatey-tests/commands/choco-install.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ To install a local, or remote file, you may use:

Context "Installing commercial package with custom commandlets" -Tag FossOnly {
BeforeAll {
New-ChocolateyInstallSnapshot
Restore-ChocolateyInstallSnapshot

$Output = Invoke-Choco install get-chocolateyunzip-licensed --confirm
}
Expand All @@ -1332,7 +1332,8 @@ To install a local, or remote file, you may use:

Context "Installing license only package on open source" -Tag FossOnly {
BeforeAll {
New-ChocolateyInstallSnapshot
Restore-ChocolateyInstallSnapshot
Enable-ChocolateySource -Name hermes-setup

$Output = Invoke-Choco install business-only-license --confirm
}
Expand Down Expand Up @@ -1456,7 +1457,6 @@ To install a local, or remote file, you may use:
Context "Installing package that makes use of new Get Chocolatey Path helper" {
BeforeAll {
Restore-ChocolateyInstallSnapshot
Enable-ChocolateySource -Name 'local'

$Output = Invoke-Choco install test-chocolateypath -y
}
Expand Down Expand Up @@ -1726,6 +1726,8 @@ To install a local, or remote file, you may use:
$null = Invoke-Choco install nuget.commandline
$null = & "$env:ChocolateyInstall/bin/nuget.exe" pack $nuspecPath

Disable-ChocolateySource -Name hermes-setup

$Output = Invoke-Choco install $packageName --source .
}

Expand Down

0 comments on commit 370e366

Please sign in to comment.