Skip to content

Commit cd6cd49

Browse files
Bump Pester to 6.1 (#475)
## Summary - pin Pester at 6.1.0 - update tests for Pester 6 mock and empty `-ForEach` behavior ## Verification - `./build.ps1 -Task Test` (249 passed, 0 failed, 2 skipped)
1 parent fc5a68e commit cd6cd49

4 files changed

Lines changed: 14 additions & 23 deletions

File tree

‎build.ps1‎

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,18 @@ if ($Bootstrap) {
8484
ErrorAction = 'Stop'
8585
}
8686

87-
$importSucceeded = $false
88-
try {
89-
Invoke-PSDepend @psDependParameters
90-
$importSucceeded = $true
91-
Write-Verbose 'Successfully imported existing modules.' -Verbose
92-
} catch {
93-
Write-Verbose "Could not import all required modules: $_" -Verbose
94-
Write-Verbose 'Attempting to install missing or outdated dependencies...' -Verbose
95-
}
87+
$psDependTestParameters = $psDependParameters.Clone()
88+
$null = $psDependTestParameters.Remove('Import')
89+
$psDependTestParameters['Test'] = $true
90+
$psDependTestParameters['Quiet'] = $true
9691

97-
if (-not $importSucceeded) {
98-
try {
99-
Invoke-PSDepend @psDependParameters -Install
100-
} catch {
101-
Write-Error "Failed to install and import required dependencies: $_"
102-
Write-Error 'This may be due to locked module files. Please restart the build environment or clear module locks.'
103-
if ($_.Exception.InnerException) {
104-
Write-Error "Inner exception: $($_.Exception.InnerException.Message)"
105-
}
106-
throw
107-
}
92+
if (-not (Invoke-PSDepend @psDependTestParameters)) {
93+
$psDependInstallParameters = $psDependParameters.Clone()
94+
$null = $psDependInstallParameters.Remove('Import')
95+
Invoke-PSDepend @psDependInstallParameters -Install
10896
}
97+
98+
Invoke-PSDepend @psDependParameters
10999
} else {
110100
if (-not (Get-Module -Name 'PSDepend' -ListAvailable)) {
111101
throw 'Missing dependencies. Please run with the "-Bootstrap" flag to install dependencies.'

‎requirements.psd1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Target = 'CurrentUser'
77
}
88
'Pester' = @{
9-
Version = '5.7.1'
9+
Version = '6.2.0'
1010
Parameters = @{
1111
SkipPublisherCheck = $true
1212
}

‎tests/Get-PlasterManifestPathForCulture.Tests.ps1‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Describe 'Get-PlasterManifestPathForCulture' {
3939

4040
It "falls back to invariant culture manifest if no specific match is found" {
4141
$culture = New-Object System.Globalization.CultureInfo("xx-XX")
42+
Mock -CommandName 'Test-Path' -MockWith { $False }
4243
Mock -CommandName 'Test-Path' -MockWith { $False } -ParameterFilter { $Path -like "*en-US*" }
4344
Mock -CommandName 'Test-Path' -MockWith { $True } -ParameterFilter { $Path -like "*fr-FR*" }
4445
Mock -CommandName 'Test-Path' -MockWith { $True } -ParameterFilter { $Path -like "*plasterManifest.xml" }

‎tests/Help.tests.ps1‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Describe "Test help for <_.Name>" -ForEach $commands {
8080
($commandHelp.Examples.Example.Remarks | Select-Object -First 1).Text | Should -Not -BeNullOrEmpty
8181
}
8282

83-
It "Help link <_> is valid" -ForEach $helpLinks {
83+
It "Help link <_> is valid" -ForEach $helpLinks -AllowNullOrEmptyForEach {
8484
(Invoke-WebRequest -Uri $_ -UseBasicParsing).StatusCode | Should -Be '200'
8585
}
8686

@@ -115,7 +115,7 @@ Describe "Test help for <_.Name>" -ForEach $commands {
115115
}
116116
}
117117

118-
Context "Test <_> help parameter help for <commandName>" -ForEach $helpParameterNames {
118+
Context "Test <_> help parameter help for <commandName>" -ForEach $helpParameterNames -AllowNullOrEmptyForEach {
119119

120120
# Shouldn't find extra parameters in help.
121121
It "finds help parameter in code: <_>" {

0 commit comments

Comments
 (0)