Skip to content

Commit

Permalink
(#2860) Add e2e tests for new PS cmdlet
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm committed Oct 18, 2022
1 parent b48e405 commit 31dd40a
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/chocolatey-tests/commands/choco-install.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1574,4 +1574,25 @@ Describe "choco install" -Tag Chocolatey, InstallCommand {
$Output.String | Should -Not -Match "- $([regex]::Escape($_))"
}
}

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
}

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

It "Outputs message <_>" -ForEach @(
'Package Path in Install Script: <installPath>\lib\test-chocolateypath'
'Install Path in Install Script: <installPath>'
"Tools Path in Install Script: $env:SystemDrive\tools"
) {
$Output.Lines | Should -Contain "$($_ -replace '<installPath>',$env:ChocolateyInstall)" -Because $Output.String
}
}
}
27 changes: 27 additions & 0 deletions tests/chocolatey-tests/commands/choco-uninstall.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,31 @@ Describe "choco uninstall" -Tag Chocolatey, UninstallCommand {
$Output.Lines | Should -Contain "Chocolatey uninstalled 1/1 packages." -Because $Output.String
}
}

Context "Uninstalling package that makes use of new Get Chocolatey Path helper" {
BeforeAll {
Restore-ChocolateyInstallSnapshot

Enable-ChocolateySource -Name 'local'

$null = Invoke-Choco install test-chocolateypath -y

$Output = Invoke-Choco uninstall test-chocolateypath -y
}

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

It "Outputs message <_>" -ForEach @(
'Package Path in Before Modify Script: <installPath>\lib\test-chocolateypath'
'Install Path in Before Modify Script: <installPath>'
"Tools Path in Before Modify Script: $env:SystemDrive\tools"
'Package Path in Uninstall Script: <installPath>\lib\test-chocolateypath'
'Install Path in Uninstall Script: <installPath>'
"Tools Path in Uninstall Script: $env:SystemDrive\tools"
) {
$Output.Lines | Should -Contain ($_ -replace '<installPath>',$env:ChocolateyInstall) -Because $Output.String
}
}
}

0 comments on commit 31dd40a

Please sign in to comment.