1
1
# Copyright (c) Microsoft Corporation.
2
2
# Licensed under the MIT License.
3
3
4
- Describe ' Configuration variables tests' {
4
+ Describe ' Configruation variables tests' {
5
5
It ' Variables example config works' {
6
- $configFile = " $PSScriptRoot /../examples/variables.dsc.yaml"
7
- $out = dsc config get -f $configFile | ConvertFrom-Json
8
- $LASTEXITCODE | Should - Be 0
9
- $out.results [0 ].result.actualState.output | Should - BeExactly ' myOutput is: Hello world!, myObject is: baz'
6
+ $configFile = " $PSSCriptRoot /../examples/variables.dsc.yaml"
7
+ $out = dsc config get -f $configFile | ConvertFrom-Json
8
+ $LASTEXITCODE | Should - Be 0
9
+ $out.results [0 ].result.actualState.output | Should - BeExactly ' myOutput is: Hello world!, myObject is: baz'
10
10
}
11
11
12
12
It ' Duplicated variable takes last value' {
13
- $configYaml = @'
13
+ $configYaml = @'
14
14
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
15
15
variables:
16
- myVariable: foo
17
- myVariable: bar
16
+ myVariable: foo
17
+ myVariable: bar
18
18
resources:
19
19
- name: test
20
- type: Microsoft.DSC.Debug/Echo
21
- properties:
22
- output: "[variables('myVariable')]"
20
+ type: Microsoft.DSC.Debug/Echo
21
+ properties:
22
+ output: "[variables('myVariable')]"
23
23
'@
24
- $out = dsc config get - i $configYaml | ConvertFrom-Json
25
- Write-Verbose - Verbose $out
26
- $LASTEXITCODE | Should - Be 0
27
- $out.results [0 ].result.actualState.output | Should - Be ' bar'
24
+ $out = dsc config get - i $configYaml | ConvertFrom-Json
25
+ Write-Verbose - Verbose $out
26
+ $LASTEXITCODE | Should - Be 0
27
+ $out.results [0 ].result.actualState.output | Should - Be ' bar'
28
28
}
29
29
30
30
It ' Missing variable returns error' {
31
- $configYaml = @'
31
+ $configYaml = @'
32
32
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
33
33
variables:
34
- hello: world
34
+ hello: world
35
35
resources:
36
36
- name: test
37
- type: Microsoft.DSC.Debug/Echo
38
- properties:
39
- output: "[variables('myVariable')]"
37
+ type: Microsoft.DSC.Debug/Echo
38
+ properties:
39
+ output: "[variables('myVariable')]"
40
40
'@
41
- $out = dsc config get - i $configYaml 2>&1 | Out-String
42
- Write-Verbose - Verbose $out
43
- $LASTEXITCODE | Should - Be 2
44
- $out | Should - BeLike " *Variable 'myVariable' does not exist or has not been initialized yet*"
41
+ $out = dsc config get - i $configYaml 2>&1 | Out-String
42
+ Write-Verbose - Verbose $out
43
+ $LASTEXITCODE | Should - Be 2
44
+ $out | Should - BeLike " *Variable 'myVariable' does not exist or has not been initialized yet*"
45
45
}
46
- }
46
+ }
0 commit comments