Skip to content

Commit 0687281

Browse files
committed
update tests
1 parent 5bab14f commit 0687281

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

dsc/tests/dsc_whatif.tests.ps1

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ Describe 'whatif tests' {
1414
properties:
1515
output: hello
1616
"@
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
2425
$LASTEXITCODE | Should -Be 0
2526
}
2627

@@ -34,19 +35,20 @@ Describe 'whatif tests' {
3435
properties:
3536
keyPath: 'HKCU\1\2'
3637
"@
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
4647
$LASTEXITCODE | Should -Be 0
48+
4749
}
4850

49-
It 'config set whatif for delete' {
51+
It 'config set whatif for delete is not supported' {
5052
$config_yaml = @"
5153
`$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/config/document.json
5254
resources:
@@ -55,14 +57,12 @@ Describe 'whatif tests' {
5557
properties:
5658
_exist: false
5759
"@
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
6363
}
6464

65-
It 'config set whatif when there is no pre-test is not supported' {
65+
It 'config set whatif for group resource' {
6666
$result = dsc config set -p $PSScriptRoot/../examples/groups.dsc.yaml -w 2>&1
6767
$result | Should -Match 'ERROR.*?Not implemented.*?what-if'
6868
$LASTEXITCODE | Should -Be 2

0 commit comments

Comments
 (0)