Skip to content

Commit 4f7ce05

Browse files
refactor: improve error handling for null property mismatches in Validate-Settings.ps1
1 parent 563d394 commit 4f7ce05

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

scripts/main.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,13 @@ if ($settings.Test.Skip) {
254254
LogGroup 'Module Local Test Suites:' {
255255
$moduleTestSuites = if ($settings.Test.Module.Skip) {
256256
Write-Host 'Skipping all module tests.'
257+
$null
257258
} else {
258259
# Locate the tests directory.
259260
$testsPath = Resolve-Path 'tests' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Path
260261
if (-not $testsPath) {
261262
Write-Warning 'No tests found'
263+
return $null
262264
}
263265
Write-Host "Tests found at [$testsPath]"
264266

tests/Validate-Settings.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ function Test-ObjectStructure {
8282
# Both null is fine
8383
Write-Host " ✓ Null property: $currentPath"
8484
} elseif (($null -eq $expectedValue -and $null -ne $actualValue) -or ($null -ne $expectedValue -and $null -eq $actualValue)) {
85-
# One null, one not - this might be okay depending on context
86-
Write-Host "Null mismatch at $currentPath (Expected: $($null -eq $expectedValue), Actual: $($null -eq $actualValue))"
85+
# One null, one not - this is an error
86+
$errors += "Null mismatch at $currentPath (Expected null: $($null -eq $expectedValue), Actual null: $($null -eq $actualValue))"
8787
}
8888
}
8989

0 commit comments

Comments
 (0)