@@ -130,31 +130,67 @@ Describe 'PowerShell adapter resource tests' {
130130 }
131131
132132 It ' Verify adapted_dsc_type field in Get' {
133- $r = ' {TestCaseId: 1}' | dsc resource get - r ' Test/TestCase'
134- $LASTEXITCODE | Should - Be 0
135- $resources = $r | ConvertFrom-Json
136- $resources.actualState.result | Should - Be $True
133+ $oldPath = $env: PATH
134+ try {
135+ $adapterPath = Join-Path $PSScriptRoot ' TestAdapter'
136+ $env: PATH += [System.IO.Path ]::PathSeparator + $adapterPath
137+
138+ $r = ' {TestCaseId: 1}' | dsc resource get - r ' Test/TestCase'
139+ $LASTEXITCODE | Should - Be 0
140+ $resources = $r | ConvertFrom-Json
141+ $resources.actualState.result | Should - Be $True
142+ }
143+ finally {
144+ $env: PATH = $oldPath
145+ }
137146 }
138147
139148 It ' Verify adapted_dsc_type field in Set' {
140- $r = ' {TestCaseId: 1}' | dsc resource set - r ' Test/TestCase'
141- $LASTEXITCODE | Should - Be 0
142- $resources = $r | ConvertFrom-Json
143- $resources.beforeState.result | Should - Be $True
144- $resources.afterState.result | Should - Be $True
149+ $oldPath = $env: PATH
150+ try {
151+ $adapterPath = Join-Path $PSScriptRoot ' TestAdapter'
152+ $env: PATH += [System.IO.Path ]::PathSeparator + $adapterPath
153+
154+ $r = ' {TestCaseId: 1}' | dsc resource set - r ' Test/TestCase'
155+ $LASTEXITCODE | Should - Be 0
156+ $resources = $r | ConvertFrom-Json
157+ $resources.beforeState.result | Should - Be $True
158+ $resources.afterState.result | Should - Be $True
159+ }
160+ finally {
161+ $env: PATH = $oldPath
162+ }
145163 }
146164
147165 It ' Verify adapted_dsc_type field in Test' {
148- $r = ' {TestCaseId: 1}' | dsc resource test - r ' Test/TestCase'
149- $LASTEXITCODE | Should - Be 0
150- $resources = $r | ConvertFrom-Json
151- $resources.actualState.result | Should - Be $True
166+ $oldPath = $env: PATH
167+ try {
168+ $adapterPath = Join-Path $PSScriptRoot ' TestAdapter'
169+ $env: PATH += [System.IO.Path ]::PathSeparator + $adapterPath
170+
171+ $r = ' {TestCaseId: 1}' | dsc resource test - r ' Test/TestCase'
172+ $LASTEXITCODE | Should - Be 0
173+ $resources = $r | ConvertFrom-Json
174+ $resources.actualState.result | Should - Be $True
175+ }
176+ finally {
177+ $env: PATH = $oldPath
178+ }
152179 }
153180
154181 It ' Verify adapted_dsc_type field in Export' {
155- $r = dsc resource export - r ' Test/TestCase'
156- $LASTEXITCODE | Should - Be 0
157- $resources = $r | ConvertFrom-Json
158- $resources.resources [0 ].properties.result | Should - Be $True
182+ $oldPath = $env: PATH
183+ try {
184+ $adapterPath = Join-Path $PSScriptRoot ' TestAdapter'
185+ $env: PATH += [System.IO.Path ]::PathSeparator + $adapterPath
186+
187+ $r = dsc resource export - r ' Test/TestCase'
188+ $LASTEXITCODE | Should - Be 0
189+ $resources = $r | ConvertFrom-Json
190+ $resources.resources [0 ].properties.result | Should - Be $True
191+ }
192+ finally {
193+ $env: PATH = $oldPath
194+ }
159195 }
160196}
0 commit comments