@@ -14,13 +14,14 @@ Describe 'whatif tests' {
14
14
properties:
15
15
output: hello
16
16
"@
17
- $result = $config_yaml | dsc config set - w -- format pretty- json | ConvertFrom-Json
18
- $result.hadErrors | Should - BeFalse
19
- $result.results.Count | Should - Be 1
20
- $result.results [0 ].Name | Should - Be ' Hello'
21
- $result.results [0 ].type | Should - BeExactly ' Test/Echo'
22
- $result.results [0 ].result.changes | Should - Be $null
23
- $result.metadata .' Microsoft.DSC' .executionType | Should - BeExactly ' WhatIf'
17
+ $what_if_result = $config_yaml | dsc config set - w | ConvertFrom-Json
18
+ $set_result = $config_yaml | dsc config set | ConvertFrom-Json
19
+ $what_if_result.metadata .' Microsoft.DSC' .executionType | Should - BeExactly ' WhatIf'
20
+ $what_if_result.results.result.beforeState.output | Should - Be $set_result.results.result.beforeState.output
21
+ $what_if_result.results.result.afterState.output | Should - Be $set_result.results.result.afterState.output
22
+ $what_if_result.results.result.changedProperties | Should - Be $set_result.results.result.changedProperties
23
+ $what_if_result.hadErrors | Should - BeFalse
24
+ $what_if_result.results.Count | Should - Be 1
24
25
$LASTEXITCODE | Should - Be 0
25
26
}
26
27
@@ -34,19 +35,20 @@ Describe 'whatif tests' {
34
35
properties:
35
36
keyPath: 'HKCU\1\2'
36
37
"@
37
- $result = $config_yaml | dsc config set - w -- format pretty - json | ConvertFrom-Json
38
- $result .hadErrors | Should - BeFalse
39
- $result .results.Count | Should - Be 1
40
- $result .results [ 0 ].Name | Should - Be ' Registry '
41
- $result .results [ 0 ].type | Should - BeExactly ' Microsoft.Windows/Registry '
42
- $result .results [ 0 ] .result.changes[ 0 ].name | Should - Be ' _exist '
43
- $result .results [ 0 ] .result.changes[ 0 ].from | Should - Be ' false '
44
- $result .results [ 0 ].result.changes[ 0 ].to | Should - Be ' true '
45
- $result .metadata . ' Microsoft.DSC ' .executionType | Should - BeExactly ' WhatIf '
38
+ $what_if_result = $config_yaml | dsc config set - w | ConvertFrom-Json
39
+ $set_result = $config_yaml | dsc config set | ConvertFrom-Json
40
+ $what_if_result .metadata . ' Microsoft.DSC ' .executionType | Should - BeExactly ' WhatIf '
41
+ $what_if_result .results.result.beforeState._exist | Should - Be $set_result .results.result.beforeState._exist
42
+ $what_if_result .results.result.beforeState.keyPath | Should - Be $set_result .results.result.beforeState.keyPath
43
+ $what_if_result .results.result.afterState.KeyPath | Should - Be $set_result .results.result.afterState.keyPath
44
+ $what_if_result .results.result.changedProperties | Should - Be $set_result .results.result.changedProperties
45
+ $what_if_result .hadErrors | Should - BeFalse
46
+ $what_if_result .results.Count | Should - Be 1
46
47
$LASTEXITCODE | Should - Be 0
48
+
47
49
}
48
50
49
- It ' config set whatif for delete' {
51
+ It ' config set whatif for delete is not supported ' {
50
52
$config_yaml = @"
51
53
`$ schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/config/document.json
52
54
resources:
@@ -55,14 +57,12 @@ Describe 'whatif tests' {
55
57
properties:
56
58
_exist: false
57
59
"@
58
- $result = $config_yaml | dsc config set - w -- format pretty- json | ConvertFrom-Json
59
- $result.hadErrors | Should - BeFalse
60
- $result.results.Count | Should - Be 1
61
- $result.results [0 ].result.changes | Should - Be " delete 'Test/Delete' using 'dsctest'"
62
- $LASTEXITCODE | Should - Be 0
60
+ $result = $config_yaml | dsc config set - w 2>&1
61
+ $result | Should -Match ' ERROR.*?Not supported.*?what-if'
62
+ $LASTEXITCODE | Should - Be 2
63
63
}
64
64
65
- It ' config set whatif when there is no pre-test is not supported ' {
65
+ It ' config set whatif for group resource ' {
66
66
$result = dsc config set - p $PSScriptRoot / ../ examples/ groups.dsc.yaml - w 2>&1
67
67
$result | Should -Match ' ERROR.*?Not implemented.*?what-if'
68
68
$LASTEXITCODE | Should - Be 2
0 commit comments