Skip to content

Commit 4af0eb4

Browse files
committed
Add invalid params test case
1 parent 57f71c8 commit 4af0eb4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

dsc/tests/dsc_parameters.tests.ps1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,4 +343,16 @@ Describe 'Parameters tests' {
343343
$errorMessage = Get-Content -Path $TestDrive/error.log -Raw
344344
$errorMessage | Should -BeLike "*ERROR*Cannot read from STDIN for both parameters and input*"
345345
}
346+
347+
It 'Invalid parameters read from STDIN result in error' {
348+
$params = @{
349+
osFamily = 'Windows'
350+
} | ConvertTo-Json -Compress
351+
352+
$out = $params | dsc config -f - test -f "$PSScriptRoot/../examples/osinfo_parameters.dsc.yaml" 2> $TestDrive/error.log
353+
$LASTEXITCODE | Should -Be 4
354+
$out | Should -BeNullOrEmpty
355+
$errorMessage = Get-Content -Path $TestDrive/error.log -Raw
356+
$errorMessage | Should -BeLike "*ERROR*Parameter input failure: JSON: missing field ````parameters````*"
357+
}
346358
}

0 commit comments

Comments
 (0)