Skip to content

Commit 87da4d0

Browse files
committed
Cast tests to string
1 parent 1d30a2f commit 87da4d0

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

docs/reference/schemas/config/functions/union.md

Whitespace-only changes.

extensions/powershell/convertDscResource.psm1

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
$Script:IsPowerShellCore = $PSVersionTable.PSEdition -eq 'Core'
2+
3+
if ($Script:IsPowerShellCore) {
4+
if ($IsWindows) {
5+
Import-Module -Name 'PSDesiredStateConfiguration' -RequiredVersion 1.1 -UseWindowsPowerShell -WarningAction SilentlyContinue
6+
}
7+
Import-Module -Name 'PSDesiredStateConfiguration' -MinimumVersion 2.0.7 -Prefix 'Pwsh' -WarningAction SilentlyContinue
8+
} else {
9+
Import-Module -Name 'PSDesiredStateConfiguration' -RequiredVersion 1.1 -WarningAction SilentlyContinue
10+
}
11+
112
function Write-DscTrace {
213
param(
314
[Parameter(Mandatory = $false)]
@@ -11,19 +22,6 @@ function Write-DscTrace {
1122
$host.ui.WriteErrorLine($trace)
1223
}
1324

14-
$Script:IsPowerShellCore = $PSVersionTable.PSEdition -eq 'Core'
15-
16-
if ($Script:IsPowerShellCore) {
17-
if ($IsWindows) {
18-
Import-Module -Name 'PSDesiredStateConfiguration' -RequiredVersion 1.1 -UseWindowsPowerShell -WarningAction SilentlyContinue
19-
}
20-
Import-Module -Name 'PSDesiredStateConfiguration' -MinimumVersion 2.0.7 -Prefix 'Pwsh' -WarningAction SilentlyContinue
21-
} else {
22-
"Loading module: 'PSDesiredStateConfiguration" | Write-DscTrace -Operation Trace
23-
"The PSModulePaths: $env:PSModulePath" | Write-DscTrace -Operation Trace
24-
Import-Module -Name 'PSDesiredStateConfiguration' -RequiredVersion 1.1 -WarningAction SilentlyContinue
25-
}
26-
2725
function Build-DscConfigDocument {
2826
[CmdletBinding()]
2927
[OutputType([System.Collections.Specialized.OrderedDictionary])]

extensions/powershell/win_powershell.tests.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ Describe 'PowerShell extension tests' {
1515
$out = dsc -l trace config get -f $psFile 2>$TestDrive/error.log | ConvertFrom-Json
1616
$LASTEXITCODE | Should -Be 0 -Because (Get-Content -Path $TestDrive/error.log -Raw | Out-String)
1717
$out.results[0].result.actualState.Ensure | Should -Be 'Absent'
18-
(Get-Content -Path $TestDrive/error.log -Raw) | Should -Match "Importing file '$psFile' with extension 'Microsoft.DSC.Extension/PowerShell'"
18+
$psFile = $psFile.ToString().Replace('\', '\\')
19+
(Get-Content -Path $TestDrive/error.log -Raw) | Should -Match "Importing file '$psFile' with extension 'Microsoft.DSC.Extension/WindowsPowerShell'"
1920
}
2021

2122
It 'Invalid PowerShell configuration document file returns error' -Skip:(!$IsWindows) {
@@ -35,7 +36,8 @@ configuration InvalidConfiguration {
3536
dsc -l trace config get -f $psFile 2>$TestDrive/error.log
3637
$LASTEXITCODE | Should -Be 2 -Because (Get-Content -Path $TestDrive/error.log -Raw | Out-String)
3738
$content = (Get-Content -Path $TestDrive/error.log -Raw)
38-
$content | Should -BeLike "*Importing file '$psFile' with extension 'Microsoft.DSC.Extension/WindowsPowerShell'*"
39+
$psFile = $psFile.ToString().Replace('\', '\\')
40+
$content | Should -Match "Importing file '$psFile' with extension 'Microsoft.DSC.Extension/WindowsPowerShell'"
3941
$content | Should -Match "No DSC resources found in the imported modules."
4042
}
4143
}

powershell-adapter/Tests/win_powershell_cache.tests.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Describe 'WindowsPowerShell adapter resource tests - requires elevated permissio
4848
}
4949

5050
It 'Get works on Binary "File" resource' {
51+
5152
$testFile = "$testdrive\test.txt"
5253
'test' | Set-Content -Path $testFile -Force
5354
$r = '{"DestinationPath":"' + $testFile.replace('\', '\\') + '"}' | dsc resource get -r 'PSDesiredStateConfiguration/File' -f -

0 commit comments

Comments
 (0)