Skip to content

Commit

Permalink
fix windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Lee (POWERSHELL HE/HIM) (from Dev Box) committed Nov 27, 2024
1 parent 66cdbc8 commit da9d8a2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
5 changes: 2 additions & 3 deletions dsc/tests/dsc_config_get.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ Describe 'dsc config get tests' {

It 'will fail if resource schema does not match' -Skip:(!$IsWindows) {
$jsonPath = Join-Path $PSScriptRoot '../examples/invalid_schema.dsc.yaml'
$config = Get-Content $jsonPath -Raw
$testError = & {$config | dsc config get -f - 2>&1}
$testError[0] | Should -match 'error:'
$testError = & {dsc config get -f $jsonPath 2>&1}
$testError[0] | Should -match 'Schema:'
$LASTEXITCODE | Should -Be 2
}

Expand Down
4 changes: 2 additions & 2 deletions dsc/tests/dsc_whatif.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Describe 'whatif tests' {
properties:
keyPath: 'HKCU\1\2'
"@
$what_if_result = $config_yaml | dsc config set -w -f - | ConvertFrom-Json
$set_result = $config_yaml | dsc config set | ConvertFrom-Json
$what_if_result = dsc config set -w -i $config_yaml | ConvertFrom-Json
$set_result = dsc config set -i $config_yaml | ConvertFrom-Json
$what_if_result.metadata.'Microsoft.DSC'.executionType | Should -BeExactly 'WhatIf'
$what_if_result.results.result.beforeState._exist | Should -Be $set_result.results.result.beforeState._exist
$what_if_result.results.result.beforeState.keyPath | Should -Be $set_result.results.result.beforeState.keyPath
Expand Down
14 changes: 7 additions & 7 deletions powershell-adapter/Tests/win_powershellgroup.tests.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

Describe 'WindowsPowerShell adapter resource tests' {
Describe 'WindowsPowerShell adapter resource tests - requires elevated permissions' {

BeforeAll {
if ($isWindows) {
Expand Down Expand Up @@ -63,12 +63,12 @@ Describe 'WindowsPowerShell adapter resource tests' {

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

$testFile = "$testdrive\test.txt"
'test' | Set-Content -Path $testFile -Force
$r = (Get-Content -Raw $winpsConfigPath).Replace('c:\test.txt',"$testFile") | dsc config get -f -
$LASTEXITCODE | Should -Be 0
$res = $r | ConvertFrom-Json
$res.results[0].result.actualState.result[0].properties.DestinationPath | Should -Be "$testFile"
$testFile = "$testdrive\test.txt"
'test' | Set-Content -Path $testFile -Force
$r = (Get-Content -Raw $winpsConfigPath).Replace('c:\test.txt',"$testFile") | dsc config get -f -
$LASTEXITCODE | Should -Be 0
$res = $r | ConvertFrom-Json
$res.results[0].result.actualState.result[0].properties.DestinationPath | Should -Be "$testFile"
}

It 'Verify that there are no cache rebuilds for several sequential executions' -Skip:(!$IsWindows) {
Expand Down
2 changes: 1 addition & 1 deletion wmi-adapter/Tests/wmi.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Describe 'WMI adapter resource tests' {

It 'Example config works' -Skip:(!$IsWindows) {
$configPath = Join-Path $PSScriptRoot '..\..\configurations\windows\windows_inventory.dsc.yaml'
$r = dsc config get -p $configPath
$r = dsc config get -f $configPath
$LASTEXITCODE | Should -Be 0
$r | Should -Not -BeNullOrEmpty
$res = $r | ConvertFrom-Json
Expand Down

0 comments on commit da9d8a2

Please sign in to comment.