Skip to content

Commit 561e40a

Browse files
committed
add test for invalid case
1 parent 38a35b0 commit 561e40a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

dsc/tests/dsc_metadata.tests.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,21 @@ Describe 'metadata tests' {
123123
$out.metadata.'Microsoft.DSC'.restartRequired[4].process.name | Should -BeExactly 'anotherProcess'
124124
$out.metadata.'Microsoft.DSC'.restartRequired[4].process.id | Should -Be 5678
125125
}
126+
127+
It 'invalid item in _restartRequired metadata is a warning' {
128+
$configYaml = @'
129+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
130+
resources:
131+
- name: test
132+
type: Test/Metadata
133+
properties:
134+
_metadata:
135+
_restartRequired:
136+
- invalid: item
137+
'@
138+
$out = dsc config get -i $configYaml 2>$TestDrive/error.log | ConvertFrom-Json
139+
$LASTEXITCODE | Should -Be 0
140+
(Get-Content $TestDrive/error.log) | Should -BeLike "*WARN*Resource returned '_metadata' property '_restartRequired' which contains invalid value: ``[{`"invalid`":`"item`"}]*"
141+
$out.results[0].metadata._restartRequired | Should -BeNullOrEmpty
142+
}
126143
}

0 commit comments

Comments
 (0)