File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,8 +14,20 @@ LogGroup 'AfterAll - Global Test Teardown' {
1414 $prefix = ' Test'
1515
1616 # Derive the list of OS names from the Settings JSON provided by Process-PSModule.
17- $settings = $env: Settings | ConvertFrom-Json
17+ try {
18+ $settings = $env: Settings | ConvertFrom-Json
19+ } catch {
20+ throw " Settings environment variable contains invalid JSON. Expected TestSuites.Module.OSName to be present. $_ "
21+ }
22+
1823 $osNames = @ ($settings.TestSuites.Module.OSName | Sort-Object - Unique)
24+ if (-not $osNames ) {
25+ throw ' Settings JSON must include at least one non-empty TestSuites.Module.OSName value.'
26+ }
27+ $invalidOsNames = @ ($osNames | Where-Object { -not $_ -or -not $_.ToString ().Trim() })
28+ if ($invalidOsNames.Count -gt 0 ) {
29+ throw ' Settings JSON contains one or more null or empty TestSuites.Module.OSName values.'
30+ }
1931 Write-Host " Cleaning up test repositories for OSes: $ ( $osNames -join ' , ' ) "
2032
2133 foreach ($authCase in $authCases ) {
Original file line number Diff line number Diff line change @@ -12,8 +12,20 @@ LogGroup 'BeforeAll - Global Test Setup' {
1212 }
1313
1414 # Derive the list of OS names from the Settings JSON provided by Process-PSModule.
15- $settings = $env: Settings | ConvertFrom-Json
15+ try {
16+ $settings = $env: Settings | ConvertFrom-Json
17+ } catch {
18+ throw " Settings environment variable does not contain valid JSON. Process-PSModule must populate it with a valid test suite configuration. $_ "
19+ }
20+
1621 $osNames = @ ($settings.TestSuites.Module.OSName | Sort-Object - Unique)
22+ if (-not $osNames ) {
23+ throw ' Settings JSON must contain TestSuites.Module.OSName with at least one OS name.'
24+ }
25+ $invalidOsNames = @ ($osNames | Where-Object { -not $_ -or -not $_.ToString ().Trim() })
26+ if ($invalidOsNames.Count -gt 0 ) {
27+ throw ' Settings JSON contains one or more null or empty values in TestSuites.Module.OSName.'
28+ }
1729 Write-Host " Creating test repositories for OSes: $ ( $osNames -join ' , ' ) "
1830
1931 foreach ($authCase in $authCases ) {
You can’t perform that action at this time.
0 commit comments