Skip to content

Commit bee85ec

Browse files
authored
Fix PS5 test failure: only mock Test-Json on PS7+ where it exists
1 parent 0bee92a commit bee85ec

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

Tests/ReadSettings.Test.ps1

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -543,19 +543,18 @@ InModuleScope ReadSettings { # Allows testing of private functions
543543

544544
It 'ValidateSettings skips validation entirely on PS versions less than 7 without warning' {
545545
Mock OutputWarning { }
546-
Mock Test-Json { }
547546

548547
$settings = @{ "someProp" = "someValue" }
549548

550-
ValidateSettings -settings $settings
551-
552549
if ($PSVersionTable.PSVersion.Major -ge 7) {
550+
Mock Test-Json { }
551+
ValidateSettings -settings $settings
553552
# On PS7+, Test-Json is called directly for validation
554553
Should -Invoke -CommandName Test-Json -Times 1
555554
}
556555
else {
557-
# On PS < 7, validation is skipped entirely
558-
Should -Invoke -CommandName Test-Json -Times 0
556+
# On PS < 7, validation is skipped entirely; Test-Json doesn't exist so we just verify no warning
557+
ValidateSettings -settings $settings
559558
}
560559

561560
# Verify no warning was output

0 commit comments

Comments
 (0)