Skip to content

Commit c31eef3

Browse files
committed
add nested test
1 parent a308268 commit c31eef3

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

dsc/tests/dsc_include.tests.ps1

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,52 @@ Describe 'Include tests' {
131131
}
132132
$out.results[0].result[0].result.actualState.family | Should -Be $expectedOS
133133
}
134+
135+
It 'Multiple includes' {
136+
$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
143+
'@
144+
145+
$echoConfigPath = Join-Path $TestDrive 'echo.dsc.yaml'
146+
$echoConfig | Set-Content -Path $echoConfigPath
147+
148+
$nestedIncludeConfig = @"
149+
`$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
150+
resources:
151+
- name: nested
152+
type: Microsoft.DSC/Include
153+
properties:
154+
configurationFile: $echoConfigPath
155+
"@
156+
157+
$nestedIncludeConfigPath = Join-Path $TestDrive 'nested_include.dsc.yaml'
158+
$nestedIncludeConfig | Set-Content -Path $nestedIncludeConfigPath
159+
160+
$includeConfig = @"
161+
`$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
162+
resources:
163+
- name: include
164+
type: Microsoft.DSC/Include
165+
properties:
166+
configurationFile: $echoConfigPath
167+
- name: include nested
168+
type: Microsoft.DSC/Include
169+
properties:
170+
configurationFile: $nestedIncludeConfigPath
171+
"@
172+
173+
$out = $includeConfig | dsc -l trace config get | ConvertFrom-Json
174+
$LASTEXITCODE | Should -Be 0
175+
$out.results[0].result[0].result.actualState.output | Should -Be 'one'
176+
$out.results[1].result[0].name | Should -Be 'nested'
177+
$out.results[1].result[0].type | Should -Be 'Microsoft.DSC/Include'
178+
$out.results[1].result[0].result[0].name | Should -Be 'one'
179+
$out.results[1].result[0].result[0].type | Should -Be 'Test/Echo'
180+
$out.results[1].result[0].result[0].result[0].actualState.output | Should -Be 'one'
181+
}
134182
}

0 commit comments

Comments
 (0)