Skip to content

Commit 2e55eb8

Browse files
author
Steve Lee (POWERSHELL HE/HIM) (from Dev Box)
committed
add test for reg key
1 parent 2e0f1d7 commit 2e55eb8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

registry/tests/registry.config.set.tests.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,24 @@ Describe 'registry config set tests' {
125125

126126
Get-ItemProperty -Path 'HKCU:\1\2' -Name 'Test' -ErrorAction Ignore | Should -BeNullOrEmpty
127127
}
128+
129+
It 'Should succeed when _exist is false and key does not exist' -Skip:(!$IsWindows) {
130+
$config = @{
131+
'$schema' = 'https://aka.ms/dsc/schemas/v3/bundled/config/document.json'
132+
resources = @(
133+
@{
134+
name = 'reg'
135+
type = 'Microsoft.Windows/Registry'
136+
properties = @{
137+
keyPath = 'HKCU\1'
138+
_exist = $false
139+
}
140+
}
141+
)
142+
}
143+
144+
$out = dsc config set -i ($config | ConvertTo-Json -Depth 10) | ConvertFrom-Json
145+
$LASTEXITCODE | Should -Be 0
146+
$out.results[0].result.afterState._exist | Should -Be $false
147+
}
128148
}

0 commit comments

Comments
 (0)