Skip to content

Commit eb9be57

Browse files
committed
remove testdrive experiment
1 parent cd877c3 commit eb9be57

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ 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 TestDrive:\test.txt -Force
29-
$r = (Get-Content -Raw $winpsConfigPath).Replace('c:\test.txt','TestDrive:\test.txt') | dsc config get
28+
$testFile = 'c:\test.txt'
29+
'test' | Set-Content -Path $testFile -Force
30+
$r = (Get-Content -Raw $winpsConfigPath).Replace('c:\test.txt',"$testFile") | dsc config get
3031
$LASTEXITCODE | Should -Be 0
3132
$res = $r | ConvertFrom-Json
32-
$res.results[0].result.actualState.result[0].properties.DestinationPath | Should -Be 'TestDrive:\test.txt'
33+
$res.results[0].result.actualState.result[0].properties.DestinationPath | Should -Be '$testFile'
3334
}
3435

3536
<#

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

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

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

33-
'test' | Set-Content -Path TestDrive:\test.txt -Force
34-
$r = '{"DestinationPath":"TestDrive:\\test.txt"}' | dsc resource get -r 'PSDesiredStateConfiguration/File'
33+
$testFile = 'c:\test.txt'
34+
'test' | Set-Content -Path $testFile -Force
35+
$r = '{"DestinationPath":"' + $testFile.replace('\','\\') + '"}' | dsc resource get -r 'PSDesiredStateConfiguration/File'
3536
$LASTEXITCODE | Should -Be 0
3637
$res = $r | ConvertFrom-Json
37-
$res.actualState.result.properties.DestinationPath | Should -Be 'TestDrive:\test.txt'
38+
$res.actualState.result.properties.DestinationPath | Should -Be "$testFile"
3839
}
3940

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

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'
43+
$testFile = 'c:\test.txt'
44+
'test' | Set-Content -Path $testFile -Force
45+
$r = '{"GetScript": "@{result = $(Get-Content ' + $testFile.replace('\','\\') + ')}", "SetScript": "throw", "TestScript": "throw"}' | dsc resource get -r 'PSDesiredStateConfiguration/Script'
4446
$LASTEXITCODE | Should -Be 0
4547
$res = $r | ConvertFrom-Json
4648
$res.actualState.result.properties.result | Should -Be 'test'

powershell-adapter/psDscAdapter/psDscAdapter.psm1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,16 @@ function Invoke-DscCacheRefresh {
6565
$Modules = Get-Module -ListAvailable
6666
}
6767

68+
$psdscVersion = Get-Module PSDesiredStateConfiguration | Sort-Object -descending | Select-Object -First 1 | ForEach-Object Version
69+
6870
foreach ($dscResource in $DscResources) {
6971
# resources that shipped in Windows should only be used with Windows PowerShell
7072
if ($dscResource.ParentPath -like "$env:windir\System32\*" -and $PSVersionTable.PSVersion.Major -gt 5) {
7173
continue
7274
}
7375

7476
# we can't run this check in PSDesiredStateConfiguration 1.1 because the property doesn't exist
75-
if ( $PSVersionTable.PSVersion.Major -gt 5 ) {
77+
if ( $psdscVersion -ge '2.0.7' ) {
7678
# only support known dscResourceType
7779
if ([dscResourceType].GetEnumNames() -notcontains $dscResource.ImplementationDetail) {
7880
$trace = @{'Debug' = 'WARNING: implementation detail not found: ' + $dscResource.ImplementationDetail } | ConvertTo-Json -Compress

0 commit comments

Comments
 (0)