Skip to content

Commit 93683be

Browse files
committed
Refactor file paths in PowerShell adapter tests to use TestDrive:\ instead of c:\ for better test isolation
1 parent 305eebe commit 93683be

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

powershell-adapter/Tests/powershellgroup.config.tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ Describe 'PowerShell adapter resource tests' {
2525

2626
It 'Get works on config with File resource for WinPS' -Skip:(!$IsWindows){
2727

28-
'test' | Set-Content -Path c:\test.txt -Force
29-
$r = Get-Content -Raw $winpsConfigPath | dsc config get
28+
'test' | Set-Content -Path TestDrive:\test.txt -Force
29+
$r = (Get-Content -Raw $winpsConfigPath).Replace('c:\test.txt','TestDrive:\test.txt') | dsc config get
3030
$LASTEXITCODE | Should -Be 0
3131
$res = $r | ConvertFrom-Json
32-
$res.results[0].result.actualState.result[0].properties.DestinationPath | Should -Be 'c:\test.txt'
32+
$res.results[0].result.actualState.result[0].properties.DestinationPath | Should -Be 'TestDrive:\test.txt'
3333
}
3434

3535
<#

powershell-adapter/Tests/powershellgroup.resource.tests.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ Describe 'PowerShell adapter resource tests' {
3030

3131
It 'Get works on Binary "File" resource' -Skip:(!$IsWindows){
3232

33-
'test' | Set-Content -Path c:\test.txt -Force
34-
$r = '{"DestinationPath":"c:\\test.txt"}' | dsc resource get -r 'PSDesiredStateConfiguration/File'
33+
'test' | Set-Content -Path TestDrive:\test.txt -Force
34+
$r = '{"DestinationPath":"TestDrive:\\test.txt"}' | dsc resource get -r 'PSDesiredStateConfiguration/File'
3535
$LASTEXITCODE | Should -Be 0
3636
$res = $r | ConvertFrom-Json
37-
$res.actualState.result.properties.DestinationPath | Should -Be 'c:\test.txt'
37+
$res.actualState.result.properties.DestinationPath | Should -Be 'TestDrive:\test.txt'
3838
}
3939

4040
It 'Get works on traditional "Script" resource' -Skip:(!$IsWindows){
4141

42-
'test' | Set-Content -Path c:\test.txt -Force
43-
$r = '{"GetScript": "@{result = $(Get-Content c:\\test.txt)}", "SetScript": "throw", "TestScript": "throw"}' | dsc resource get -r 'PSDesiredStateConfiguration/Script'
42+
'test' | Set-Content -Path TestDrive:\test.txt -Force
43+
$r = '{"GetScript": "@{result = $(Get-Content TestDrive:\\test.txt)}", "SetScript": "throw", "TestScript": "throw"}' | dsc resource get -r 'PSDesiredStateConfiguration/Script'
4444
$LASTEXITCODE | Should -Be 0
4545
$res = $r | ConvertFrom-Json
4646
$res.actualState.result.properties.result | Should -Be 'test'

0 commit comments

Comments
 (0)