@@ -5,7 +5,8 @@ Describe 'Discover extension tests' {
5
5
BeforeAll {
6
6
$oldPath = $env: PATH
7
7
$separator = [System.IO.Path ]::PathSeparator
8
- $env: PATH = " $PSScriptRoot $separator$oldPath "
8
+ $toolPath = Resolve-Path - Path " $PSScriptRoot /../../extensions/test/discover"
9
+ $env: PATH = " $toolPath$separator$oldPath "
9
10
}
10
11
11
12
AfterAll {
@@ -50,4 +51,43 @@ Describe 'Discover extension tests' {
50
51
$out.results [1 ].type | Should - BeExactly ' Test/DiscoveredTwo'
51
52
$out.results [1 ].result.actualState.Output | Should - BeExactly ' Hello Two'
52
53
}
54
+
55
+ It ' Relative path from discovery will fail' {
56
+ $extension_json = @'
57
+ {
58
+ "$schema": "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json",
59
+ "type": "Test/DiscoverRelative",
60
+ "version": "0.1.0",
61
+ "description": "Test discover resource",
62
+ "discover": {
63
+ "executable": "pwsh",
64
+ "args": [
65
+ "-NoLogo",
66
+ "-NonInteractive",
67
+ "-NoProfile",
68
+ "-Command",
69
+ "./discover.ps1",
70
+ "-RelativePath"
71
+ ]
72
+ }
73
+ }
74
+ '@
75
+ Set-Content - Path " $TestDrive /test.dsc.extension.json" - Value $extension_json
76
+ Copy-Item - Path " $toolPath /discover.ps1" - Destination $TestDrive | Out-Null
77
+ Copy-Item - Path " $toolPath /resources" - Destination $TestDrive - Recurse | Out-Null
78
+ $env: DSC_RESOURCE_PATH = $TestDrive
79
+ try {
80
+ $out = dsc extension list | ConvertFrom-Json
81
+ $out.Count | Should - Be 1
82
+ $out.type | Should - Be ' Test/DiscoverRelative'
83
+ $out = dsc resource list 2> $TestDrive / error.log
84
+ write-verbose - verbose (Get-Content - Path " $TestDrive /error.log" - Raw)
85
+ $LASTEXITCODE | Should - Be 0
86
+ $out | Should - BeNullOrEmpty
87
+ $errorMessage = Get-Content - Path " $TestDrive /error.log" - Raw
88
+ $errorMessage | Should - BeLike ' *is not an absolute path*'
89
+ } finally {
90
+ $env: DSC_RESOURCE_PATH = $null
91
+ }
92
+ }
53
93
}
0 commit comments