Skip to content

Commit ca2473d

Browse files
committed
Fix tests
1 parent 9aa9eb6 commit ca2473d

File tree

7 files changed

+8
-25
lines changed

7 files changed

+8
-25
lines changed

dsc/tests/dsc_extension_discover.tests.ps1

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
Describe 'Discover extension tests' {
55
BeforeAll {
66
$oldPath = $env:PATH
7-
$separator = [System.IO.Path]::PathSeparator
87
$toolPath = Resolve-Path -Path "$PSScriptRoot/../../extensions/test/discover"
9-
$env:PATH = "$toolPath$separator$oldPath"
8+
$env:PATH = $toolPath + [System.IO.Path]::PathSeparator + $oldPath
109
}
1110

1211
AfterAll {
@@ -75,7 +74,7 @@ Describe 'Discover extension tests' {
7574
Set-Content -Path "$TestDrive/test.dsc.extension.json" -Value $extension_json
7675
Copy-Item -Path "$toolPath/discover.ps1" -Destination $TestDrive | Out-Null
7776
Copy-Item -Path "$toolPath/resources" -Destination $TestDrive -Recurse | Out-Null
78-
$env:DSC_RESOURCE_PATH = $TestDrive
77+
$env:DSC_RESOURCE_PATH = "$TestDrive$separator$oldPath"
7978
try {
8079
$out = dsc extension list | ConvertFrom-Json
8180
$out.Count | Should -Be 1

dsc/tests/dsc_resource_input.tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Describe 'tests for resource input' {
8585
}
8686
'@
8787
$oldPath = $env:DSC_RESOURCE_PATH
88-
$env:DSC_RESOURCE_PATH = $TestDrive
88+
$env:DSC_RESOURCE_PATH = $TestDrive + [System.IO.Path]::PathSeparator + $env:PATH
8989
Set-Content $TestDrive/EnvVarInput.dsc.resource.json -Value $manifest
9090
}
9191

dsc/tests/dsc_set.tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ changedProperties:
147147

148148
$oldPath = $env:DSC_RESOURCE_PATH
149149
try {
150-
$env:DSC_RESOURCE_PATH = $TestDrive
150+
$env:DSC_RESOURCE_PATH = $TestDrive + [System.IO.Path]::PathSeparator + $env:PATH
151151
$out = '{ "test": true }' | dsc resource set -r Test/SetNoTest -f - --output-format $format | Out-String
152152
$LASTEXITCODE | Should -Be 0
153153
$out.Trim() | Should -BeExactly $expected
@@ -160,7 +160,7 @@ changedProperties:
160160
It 'set can be used on a resource that does not implement test' {
161161
$oldPath = $env:DSC_RESOURCE_PATH
162162
try {
163-
$env:DSC_RESOURCE_PATH = $TestDrive
163+
$env:DSC_RESOURCE_PATH = $TestDrive + [System.IO.Path]::PathSeparator + $env:PATH
164164
$out = '{ "test": true }' | dsc resource set -r Test/SetNoTest -f - | ConvertFrom-Json
165165
$LASTEXITCODE | Should -Be 0
166166
$out.BeforeState.test | Should -Be $true

dsc_lib/locales/en-us.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ couldNotReadSetting = "Could not read 'resourcePath' setting"
7272
appendingEnvPath = "Appending PATH to resourcePath"
7373
originalPath = "Original PATH: %{path}"
7474
failedGetEnvPath = "Failed to get PATH environment variable"
75+
failedJoinEnvPath = "Failed to join PATH environment variable"
7576
exeHomeAlreadyInPath = "Exe home is already in path: %{path}"
7677
addExeHomeToPath = "Adding exe home to path: %{path}"
7778
usingResourcePath = "Using Resource Path: %{path}"

dsc_lib/src/discovery/command_discovery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl CommandDiscovery {
155155
if let Ok(new_path) = env::join_paths(paths.clone()) {
156156
env::set_var("PATH", new_path);
157157
} else {
158-
return Err(DscError::Operation(t!("discovery.commandDiscovery.failedSetEnvPath").to_string()));
158+
return Err(DscError::Operation(t!("discovery.commandDiscovery.failedJoinEnvPath").to_string()));
159159
}
160160
} else {
161161
// if exe home is not already in PATH env var then add it to env var and list of searched paths

runcommandonset/tests/runcommandonset.get.tests.ps1

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22
# Licensed under the MIT License.
33

44
Describe 'tests for runcommandonset get' {
5-
BeforeAll {
6-
$oldPath = $env:DSC_RESOURCE_PATH
7-
$env:DSC_RESOURCE_PATH = Join-Path $PSScriptRoot ".."
8-
}
9-
10-
AfterAll {
11-
$env:DSC_RESOURCE_PATH = $oldPath
12-
}
13-
145
It 'Input passed for executable, arguments, and exit code' {
156
$json = @"
167
{
@@ -21,6 +12,7 @@ Describe 'tests for runcommandonset get' {
2112
"@
2213

2314
$result = $json | dsc resource get -r Microsoft.DSC.Transitional/RunCommandOnSet -f - | ConvertFrom-Json
15+
$LASTEXITCODE | Should -Be 0
2416
$result.actualState.arguments | Should -BeExactly @('bar', 'baz')
2517
$result.actualState.executable | Should -BeExactly 'foo'
2618
$result.actualState.exitCode | Should -BeExactly 5

runcommandonset/tests/runcommandonset.set.tests.ps1

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,12 @@
22
# Licensed under the MIT License.
33

44
Describe 'tests for runcommandonset set' {
5-
BeforeAll {
6-
$oldPath = $env:DSC_RESOURCE_PATH
7-
$env:DSC_RESOURCE_PATH = Join-Path $PSScriptRoot ".."
8-
}
9-
105
AfterEach {
116
if (Test-Path $TestDrive/output.txt) {
127
Remove-Item -Path $TestDrive/output.txt
138
}
149
}
1510

16-
AfterAll {
17-
$env:DSC_RESOURCE_PATH = $oldPath
18-
}
19-
2011
It 'Input for executable and arguments can be sent to the resource' {
2112
$input_json = @"
2213
{

0 commit comments

Comments
 (0)