@@ -133,36 +133,47 @@ Write-Host 'Hello from TestModule!'
133
133
$yaml = @"
134
134
`$ schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
135
135
resources:
136
- - name: File resource
137
- type: PSDesiredStateConfiguration/File
136
+ - name: File
137
+ type: Microsoft.Windows/WindowsPowerShell
138
138
properties:
139
- DestinationPath: $testdrive \test.txt
140
- - name: File assertion
139
+ resources:
140
+ - name: File
141
+ type: PSDesiredStateConfiguration/File
142
+ properties:
143
+ DestinationPath: $testdrive \test.txt
144
+ - name: File present
141
145
type: Microsoft.DSC/Assertion
142
146
properties:
143
- `$ schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
144
- resources:
145
- - name: File
146
- type: PSDesiredStateConfiguration/File
147
- properties:
148
- DestinationPath: $testdrive \test.txt
147
+ `$ schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
148
+ resources:
149
+ - name: Use powershell adapter
150
+ type: Microsoft.Windows/WindowsPowerShell
151
+ properties:
152
+ resources:
153
+ - name: File present
154
+ type: PSDesiredStateConfiguration/File
155
+ properties:
156
+ DestinationPath: $testDrive \test.txt
149
157
dependsOn:
150
- - "[resourceId('PSDesiredStateConfiguration/File ', 'File resource ')]"
158
+ - "[resourceId('Microsoft.Windows/WindowsPowerShell ', 'File')]"
151
159
- name: TestPSRepository
152
160
type: DscResources/TestPSRepository
153
161
properties:
154
162
Name: NuGet
155
163
dependsOn:
156
- - "[resourceId('PSDesiredStateConfiguration/File ', 'File resource ')]"
157
- - "[resourceId('Microsoft.DSC/Assertion', 'File assertion ')]"
164
+ - "[resourceId('Microsoft.Windows/WindowsPowerShell ', 'File')]"
165
+ - "[resourceId('Microsoft.DSC/Assertion', 'File present ')]"
158
166
"@
159
- $r = dsc config test - i $yaml | ConvertFrom-Json
167
+ # outputting to file because dsc doesn't handle the yaml string correctly when dependsOn is used
168
+ $filePath = " $testdrive \test.assertion.dsc.resource.yaml"
169
+ $yaml | Set-Content - Path $filePath - Force
170
+ $r = dsc config test -f $filePath | ConvertFrom-Json
171
+ $r = dsc config test -f " $testdrive \test.assertion.dsc.resource.yaml" | ConvertFrom-Json
160
172
$LASTEXITCODE | Should - Be 0
161
173
$r.results [0 ].result.inDesiredState | Should - Be $true
162
174
$cache = Get-Content - Raw - Path $cacheFilePath
163
175
$cache.ResourceCache | Should - Contain @ (' DscResources/TestPSRepository' , ' PSDesiredStateConfiguration/File' )
164
176
165
-
166
177
# Clean up the test module directory
167
178
Remove-Item - Path " $testModuleDir " - Recurse - Force - ErrorAction Ignore
168
179
}
0 commit comments