Skip to content

Commit 041d71e

Browse files
author
Steve Lee (POWERSHELL HE/HIM) (from Dev Box)
committed
fix test by escaping backslashes
1 parent 339765f commit 041d71e

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

dsc/tests/dsc_include.tests.ps1

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -134,43 +134,44 @@ Describe 'Include tests' {
134134

135135
It 'Multiple includes' {
136136
$echoConfig = @'
137-
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
138-
resources:
139-
- name: one
140-
type: Test/Echo
141-
properties:
142-
output: one
137+
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
138+
resources:
139+
- name: one
140+
type: Test/Echo
141+
properties:
142+
output: one
143143
'@
144144

145145
$echoConfigPath = Join-Path $TestDrive 'echo.dsc.yaml'
146-
$echoConfig | Set-Content -Path $echoConfigPath
147-
$echoConfigPathParent = Split-Path $echoConfigPath -Parent
148-
$echoConfigPathLeaf = Split-Path $echoConfigPath -Leaf
149-
$directorySeparator = [System.IO.Path]::DirectorySeparatorChar
146+
$echoConfig | Set-Content -Path $echoConfigPath -Encoding utf8
147+
# need to escape backslashes for YAML
148+
$echoConfigPathParent = (Split-Path $echoConfigPath -Parent).Replace('\', '\\')
149+
$echoConfigPathLeaf = (Split-Path $echoConfigPath -Leaf).Replace('\', '\\')
150+
$directorySeparator = [System.IO.Path]::DirectorySeparatorChar.ToString().Replace('\', '\\')
150151

151152
$nestedIncludeConfig = @"
152-
`$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
153-
resources:
154-
- name: nested
155-
type: Microsoft.DSC/Include
156-
properties:
157-
configurationFile: "[concat('$echoConfigPathParent', '$directorySeparator', '$echoConfigPathLeaf')]"
153+
`$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
154+
resources:
155+
- name: nested
156+
type: Microsoft.DSC/Include
157+
properties:
158+
configurationFile: "[concat('$echoConfigPathParent', '$directorySeparator', '$echoConfigPathLeaf')]"
158159
"@
159160

160161
$nestedIncludeConfigPath = Join-Path $TestDrive 'nested_include.dsc.yaml'
161-
$nestedIncludeConfig | Set-Content -Path $nestedIncludeConfigPath
162+
$nestedIncludeConfig | Set-Content -Path $nestedIncludeConfigPath -Encoding utf8
162163

163164
$includeConfig = @"
164-
`$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
165-
resources:
166-
- name: include
167-
type: Microsoft.DSC/Include
168-
properties:
169-
configurationFile: $echoConfigPath
170-
- name: include nested
171-
type: Microsoft.DSC/Include
172-
properties:
173-
configurationFile: $nestedIncludeConfigPath
165+
`$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
166+
resources:
167+
- name: include
168+
type: Microsoft.DSC/Include
169+
properties:
170+
configurationFile: $echoConfigPath
171+
- name: include nested
172+
type: Microsoft.DSC/Include
173+
properties:
174+
configurationFile: $nestedIncludeConfigPath
174175
"@
175176

176177
$out = $includeConfig | dsc config get | ConvertFrom-Json

0 commit comments

Comments
 (0)