Skip to content

Commit a331093

Browse files
committed
Refactor DSCv3 integration tests to streamline result handling and enhance verbose output
1 parent 258b398 commit a331093

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

tests/Integration/Resources/DSCv3_DebugDscEngine.Integration.Tests.ps1

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,16 @@ Describe "$($script:dscResourceFriendlyName)_Integration" -Tag @('Integration_SQ
186186
WriteProperty = 'NewDesiredValue'
187187
}
188188

189-
{
190-
$result = dsc --trace-level trace resource set --resource SqlServerDsc/DebugDscEngine --output-format json --input ($desiredParameters | ConvertTo-Json -Compress) | ConvertFrom-Json
189+
$result = dsc --trace-level trace resource set --resource SqlServerDsc/DebugDscEngine --output-format json --input ($desiredParameters | ConvertTo-Json -Compress) | ConvertFrom-Json
191190

192-
$dscExitCode = $LASTEXITCODE # cSpell: ignore LASTEXITCODE
191+
$dscExitCode = $LASTEXITCODE # cSpell: ignore LASTEXITCODE
193192

194-
if ($dscExitCode -ne 0)
195-
{
196-
throw ('DSC executable failed with exit code {0}.' -f $dscExitCode)
197-
}
193+
if ($dscExitCode -ne 0)
194+
{
195+
throw ('DSC executable failed with exit code {0}.' -f $dscExitCode)
196+
}
198197

199-
Write-Verbose -Message "Result (all):`n$($result | ConvertTo-Json | Out-String)" -Verbose
200-
} | Should -Not -Throw
198+
Write-Verbose -Message "Result (all):`n$($result | ConvertTo-Json | Out-String)" -Verbose
201199
}
202200

203201
It 'Should handle property normalization during set operation' {
@@ -207,18 +205,20 @@ Describe "$($script:dscResourceFriendlyName)_Integration" -Tag @('Integration_SQ
207205
WriteProperty = ' SpacedValue '
208206
}
209207

210-
{
211-
$result = dsc --trace-level trace resource set --resource SqlServerDsc/DebugDscEngine --output-format json --input ($desiredParameters | ConvertTo-Json -Compress) | ConvertFrom-Json
208+
$result = dsc --trace-level trace resource set --resource SqlServerDsc/DebugDscEngine --output-format json --input ($desiredParameters | ConvertTo-Json -Compress) | ConvertFrom-Json
212209

213-
$dscExitCode = $LASTEXITCODE # cSpell: ignore LASTEXITCODE
210+
$dscExitCode = $LASTEXITCODE # cSpell: ignore LASTEXITCODE
211+
Write-Verbose -Message "DSCv3 exit code: $($dscExitCode | Out-String)" -Verbose
212+
Write-Verbose -Message "DSCv3 exit code type: $($dscExitCode.GetType().FullName | Out-String)" -Verbose
214213

215-
if ($dscExitCode -ne 0)
216-
{
217-
throw ('DSC executable failed with exit code {0}.' -f $dscExitCode)
218-
}
219214

220-
Write-Verbose -Message "Result (all):`n$($result | ConvertTo-Json | Out-String)" -Verbose
221-
} | Should -Not -Throw
215+
if ($dscExitCode -ne 0)
216+
{
217+
throw ('DSC executable failed with exit code {0}.' -f $dscExitCode)
218+
}
219+
220+
Write-Verbose -Message "DSCv3 exit code: $($dscExitCode | Out-String)" -Verbose
221+
Write-Verbose -Message "Result (all):`n$($result | ConvertTo-Json | Out-String)" -Verbose
222222
}
223223
}
224224

@@ -285,16 +285,14 @@ Describe "$($script:dscResourceFriendlyName)_Integration" -Tag @('Integration_SQ
285285
#}
286286
}
287287

288-
{
289-
$result = dsc --trace-level trace resource get --resource SqlServerDsc/DebugDscEngine --output-format json --input ($desiredParameters | ConvertTo-Json -Compress) | ConvertFrom-Json
288+
$result = dsc --trace-level trace resource get --resource SqlServerDsc/DebugDscEngine --output-format json --input ($desiredParameters | ConvertTo-Json -Compress) | ConvertFrom-Json
290289

291-
$dscExitCode = $LASTEXITCODE # cSpell: ignore LASTEXITCODE
290+
$dscExitCode = $LASTEXITCODE # cSpell: ignore LASTEXITCODE
292291

293-
if ($dscExitCode -ne 0)
294-
{
295-
throw ('DSC executable failed with exit code {0}.' -f $dscExitCode)
296-
}
297-
} | Should -Not -Throw
292+
if ($dscExitCode -ne 0)
293+
{
294+
throw ('DSC executable failed with exit code {0}.' -f $dscExitCode)
295+
}
298296
}
299297
}
300298
}

0 commit comments

Comments
 (0)