Skip to content

Commit

Permalink
Convert and pin to Pester v4 (#22)
Browse files Browse the repository at this point in the history
* Fix Should syntax with Pester 3-to-4

* Pin Pester to v4
  • Loading branch information
ethanbergstrom committed Apr 3, 2021
1 parent 6168877 commit d7339be
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
62 changes: 31 additions & 31 deletions Test/ChocolateyGet.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ Describe "$platform basic package search operations" {
$package = 'cpu-z'

It 'gets a list of latest installed packages' {
Get-Package -Provider $ChocolateyGet | Where-Object {$_.Name -contains 'chocolatey'} | Should Not BeNullOrEmpty
Get-Package -Provider $ChocolateyGet | Where-Object {$_.Name -contains 'chocolatey'} | Should -Not -BeNullOrEmpty
}
It 'searches for the latest version of a package' {
Find-Package -Provider $ChocolateyGet -Name $package | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty
Find-Package -Provider $ChocolateyGet -Name $package | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}
It 'searches for all versions of a package' {
Find-Package -Provider $ChocolateyGet -Name $package -AllVersions | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty
Find-Package -Provider $ChocolateyGet -Name $package -AllVersions | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}
It 'searches for the latest version of a package with a wildcard pattern' {
Find-Package -Provider $ChocolateyGet -Name "$package*" | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty
Find-Package -Provider $ChocolateyGet -Name "$package*" | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}
}
Context 'with additional arguments' {
$package = 'cpu-z'
$argsAndParams = '--exact'

It 'searches for the exact package name' {
Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Should Not BeNullOrEmpty
Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Should -Not -BeNullOrEmpty
}
}
}
Expand All @@ -40,33 +40,33 @@ Describe "$platform DSC-compliant package installation and uninstallation" {
$package = 'cpu-z'

It 'searches for the latest version of a package' {
Find-Package -Provider $ChocolateyGet -Name $package | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty
Find-Package -Provider $ChocolateyGet -Name $package | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}
It 'silently installs the latest version of a package' {
Install-Package -Provider $ChocolateyGet -Name $package -Force | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty
Install-Package -Provider $ChocolateyGet -Name $package -Force | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}
It 'finds the locally installed package just installed' {
Get-Package -Provider $ChocolateyGet -Name $package | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty
Get-Package -Provider $ChocolateyGet -Name $package | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}
It 'silently uninstalls the locally installed package just installed' {
Uninstall-Package -Provider $ChocolateyGet -Name $package | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty
Uninstall-Package -Provider $ChocolateyGet -Name $package | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}
}
Context 'with additional arguments' {
$package = 'sysinternals'
$argsAndParams = '--paramsglobal --params "/InstallDir='+$env:TEMP+'\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false'

It 'searches for the latest version of a package' {
Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty
Find-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}
It 'silently installs the latest version of a package' {
Install-Package -Force -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty
Install-Package -Force -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}
It 'finds the locally installed package just installed' {
Get-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty
Get-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}
It 'silently uninstalls the locally installed package just installed' {
Uninstall-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty
Uninstall-Package -Provider $ChocolateyGet -Name $package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}
}
}
Expand All @@ -76,22 +76,22 @@ Describe "$platform pipline-based package installation and uninstallation" {
$package = 'cpu-z'

It 'searches for and silently installs the latest version of a package' {
Find-Package -Provider $ChocolateyGet -Name $package | Install-Package -Force | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty
Find-Package -Provider $ChocolateyGet -Name $package | Install-Package -Force | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}
It 'finds and silently uninstalls the locally installed package just installed' {
Get-Package -Provider $ChocolateyGet -Name $package | Uninstall-Package | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty
Get-Package -Provider $ChocolateyGet -Name $package | Uninstall-Package | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}
}
Context 'with additional arguments' {
$package = 'sysinternals'
$argsAndParams = '--paramsglobal --params "/InstallDir='+$env:TEMP+'\sysinternals /QuickLaunchShortcut=false" -y --installargs MaintenanceService=false'

It 'searches for and silently installs the latest version of a package' {
Find-Package -Provider $ChocolateyGet -Name $package | Install-Package -Force -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty
Find-Package -Provider $ChocolateyGet -Name $package | Install-Package -Force -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}

It 'finds and silently uninstalls the locally installed package just installed' {
Get-Package -Provider $ChocolateyGet -Name $package | Uninstall-Package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty
Get-Package -Provider $ChocolateyGet -Name $package | Uninstall-Package -AdditionalArguments $argsAndParams | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}
}
}
Expand All @@ -111,20 +111,20 @@ Describe "$platform multi-source support" {
}

It 'refuses to register a source with no location' {
Register-PackageSource -Name $altSourceName -Provider $ChocolateyGet -ErrorAction SilentlyContinue | Where-Object {$_.Name -eq $altSourceName} | Should BeNullOrEmpty
Register-PackageSource -Name $altSourceName -Provider $ChocolateyGet -ErrorAction SilentlyContinue | Where-Object {$_.Name -eq $altSourceName} | Should -BeNullOrEmpty
}
It 'registers an alternative package source' {
Register-PackageSource -Name $altSourceName -Provider $ChocolateyGet -Location $altSourceLocation | Where-Object {$_.Name -eq $altSourceName} | Should Not BeNullOrEmpty
Register-PackageSource -Name $altSourceName -Provider $ChocolateyGet -Location $altSourceLocation | Where-Object {$_.Name -eq $altSourceName} | Should -Not -BeNullOrEmpty
}
It 'searches for and installs the latest version of a package from an alternate source' {
Find-Package -Provider $ChocolateyGet -Name $package -source $altSourceName | Install-Package -Force | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty
Find-Package -Provider $ChocolateyGet -Name $package -source $altSourceName | Install-Package -Force | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}
It 'finds and uninstalls a package installed from an alternate source' {
Get-Package -Provider $ChocolateyGet -Name $package | Uninstall-Package | Where-Object {$_.Name -contains $package} | Should Not BeNullOrEmpty
Get-Package -Provider $ChocolateyGet -Name $package | Uninstall-Package | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}
It 'unregisters an alternative package source' {
Unregister-PackageSource -Name $altSourceName -Provider $ChocolateyGet
Get-PackageSource -Provider $ChocolateyGet | Where-Object {$_.Name -eq $altSourceName} | Should BeNullOrEmpty
Get-PackageSource -Provider $ChocolateyGet | Where-Object {$_.Name -eq $altSourceName} | Should -BeNullOrEmpty
}
}

Expand All @@ -139,41 +139,41 @@ Describe "$platform version filters" {

Context 'required version' {
It 'searches for and silently installs a specific package version' {
Find-Package -Provider $ChocolateyGet -Name $package -RequiredVersion $version | Install-Package -Force | Where-Object {$_.Name -contains $package -and $_.Version -eq $version} | Should Not BeNullOrEmpty
Find-Package -Provider $ChocolateyGet -Name $package -RequiredVersion $version | Install-Package -Force | Where-Object {$_.Name -contains $package -and $_.Version -eq $version} | Should -Not -BeNullOrEmpty
}
It 'finds and silently uninstalls a specific package version' {
Get-Package -Provider $ChocolateyGet -Name $package -RequiredVersion $version | UnInstall-Package -Force | Where-Object {$_.Name -contains $package -and $_.Version -eq $version} | Should Not BeNullOrEmpty
Get-Package -Provider $ChocolateyGet -Name $package -RequiredVersion $version | UnInstall-Package -Force | Where-Object {$_.Name -contains $package -and $_.Version -eq $version} | Should -Not -BeNullOrEmpty
}
}

Context 'minimum version' {
It 'searches for and silently installs a minimum package version' {
Find-Package -Provider $ChocolateyGet -Name $package -MinimumVersion $version | Install-Package -Force | Where-Object {$_.Name -contains $package -and $_.Version -ge $version} | Should Not BeNullOrEmpty
Find-Package -Provider $ChocolateyGet -Name $package -MinimumVersion $version | Install-Package -Force | Where-Object {$_.Name -contains $package -and $_.Version -ge $version} | Should -Not -BeNullOrEmpty
}
It 'finds and silently uninstalls a minimum package version' {
Get-Package -Provider $ChocolateyGet -Name $package -MinimumVersion $version | UnInstall-Package -Force | Where-Object {$_.Name -contains $package -and $_.Version -ge $version} | Should Not BeNullOrEmpty
Get-Package -Provider $ChocolateyGet -Name $package -MinimumVersion $version | UnInstall-Package -Force | Where-Object {$_.Name -contains $package -and $_.Version -ge $version} | Should -Not -BeNullOrEmpty
}
}

Context 'maximum version' {
It 'searches for and silently installs a maximum package version' {
Find-Package -Provider $ChocolateyGet -Name $package -MaximumVersion $version | Install-Package -Force | Where-Object {$_.Name -contains $package -and $_.Version -le $version} | Should Not BeNullOrEmpty
Find-Package -Provider $ChocolateyGet -Name $package -MaximumVersion $version | Install-Package -Force | Where-Object {$_.Name -contains $package -and $_.Version -le $version} | Should -Not -BeNullOrEmpty
}
It 'finds and silently uninstalls a maximum package version' {
Get-Package -Provider $ChocolateyGet -Name $package -MaximumVersion $version | UnInstall-Package -Force | Where-Object {$_.Name -contains $package -and $_.Version -le $version} | Should Not BeNullOrEmpty
Get-Package -Provider $ChocolateyGet -Name $package -MaximumVersion $version | UnInstall-Package -Force | Where-Object {$_.Name -contains $package -and $_.Version -le $version} | Should -Not -BeNullOrEmpty
}
}

Context '"latest" version' {
It 'does not find the "latest" locally installed version if an outdated version is installed' {
Install-Package -name $package -requiredVersion $version -Provider $ChocolateyGet -Force
Get-Package -Provider $ChocolateyGet -Name $package -RequiredVersion 'latest' -ErrorAction SilentlyContinue | Where-Object {$_.Name -contains $package} | Should BeNullOrEmpty
Get-Package -Provider $ChocolateyGet -Name $package -RequiredVersion 'latest' -ErrorAction SilentlyContinue | Where-Object {$_.Name -contains $package} | Should -BeNullOrEmpty
}
It 'searches for and silently installs the latest package version' {
Find-Package -Provider $ChocolateyGet -Name $package -RequiredVersion 'latest' | Install-Package -Force | Where-Object {$_.Name -contains $package -and $_.Version -gt $version} | Should Not BeNullOrEmpty
Find-Package -Provider $ChocolateyGet -Name $package -RequiredVersion 'latest' | Install-Package -Force | Where-Object {$_.Name -contains $package -and $_.Version -gt $version} | Should -Not -BeNullOrEmpty
}
It 'finds and silently uninstalls a specific package version' {
Get-Package -Provider $ChocolateyGet -Name $package -RequiredVersion 'latest' | UnInstall-Package -Force | Where-Object {$_.Name -contains $package -and $_.Version -gt $version} | Should Not BeNullOrEmpty
Get-Package -Provider $ChocolateyGet -Name $package -RequiredVersion 'latest' | UnInstall-Package -Force | Where-Object {$_.Name -contains $package -and $_.Version -gt $version} | Should -Not -BeNullOrEmpty
}
}
}
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ image: Visual Studio 2019
install:
- dotnet tool restore
- dotnet paket restore
- cinst pester
- cinst pester --version 4.10.1

build_script:
- ps: |
Expand Down

0 comments on commit d7339be

Please sign in to comment.