Skip to content

Commit 4dd6735

Browse files
committed
Fix Copilot + add regression test
1 parent c8662b3 commit 4dd6735

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

extensions/powershell/powershell.discover.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,14 @@ function Invoke-DscResourceDiscovery {
7474
$manifests = $cache.Manifests
7575
} else {
7676
$manifests = $psPaths | ForEach-Object -Parallel {
77-
$searchPatterns = @('*.dsc.resource.json', '*.dsc.resource.yaml', '*.dsc.resource.yml', '*.dsc.adaptedresource.json', '*.dsc.adaptedresource.yaml', '*.dsc.adaptedresource.yml')
77+
$searchPatterns = @(
78+
'*.dsc.resource.json'
79+
'*.dsc.resource.yaml'
80+
'*.dsc.resource.yml'
81+
'*.dsc.adaptedresource.json'
82+
'*.dsc.adaptedresource.yaml'
83+
'*.dsc.adaptedresource.yml'
84+
)
7885
$enumOptions = [System.IO.EnumerationOptions]@{ IgnoreInaccessible = $true; RecurseSubdirectories = $true }
7986
foreach ($pattern in $searchPatterns) {
8087
try {

extensions/powershell/powershell.discover.tests.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,32 @@ BeforeAll {
2020

2121
$manifestPath = Join-Path $TestDrive "fake.dsc.resource.json"
2222
$fakeManifest | ConvertTo-Json -Depth 10 | Set-Content -Path $manifestPath
23+
24+
$fakeAdaptedManifest = @{
25+
'$schema' = "https://aka.ms/dsc/schemas/v3/bundled/adaptedresource/manifest.json"
26+
type = "Test/FakeAdaptedResource"
27+
kind = "resource"
28+
version = "0.1.0"
29+
capabilities = @("get", "set", "test")
30+
description = "A fake adapted resource for regression testing."
31+
requireAdapter = "Microsoft.Adapter/PowerShell"
32+
path = "FakeAdapted.psd1"
33+
schema = @{
34+
embedded = @{
35+
'$schema' = "https://json-schema.org/draft/2020-12/schema"
36+
title = "Test/FakeAdaptedResource"
37+
type = "object"
38+
required = @("Name")
39+
additionalProperties = $false
40+
properties = @{
41+
Name = @{ type = "string"; title = "Name"; description = "The name." }
42+
}
43+
}
44+
}
45+
}
46+
47+
$adaptedManifestPath = Join-Path $TestDrive "fake.dsc.adaptedresource.json"
48+
$fakeAdaptedManifest | ConvertTo-Json -Depth 10 | Set-Content -Path $adaptedManifestPath
2349
$script:OldPSModulePath = $env:PSModulePath
2450
$env:PSModulePath += [System.IO.Path]::PathSeparator + $TestDrive
2551

@@ -127,4 +153,10 @@ Describe 'Tests for PowerShell resource discovery' {
127153
$out = & $script:discoverScript | ConvertFrom-Json
128154
$out.manifestPath | Should -Contain $manifestPath
129155
}
156+
157+
It 'Should discover adapted resource manifest files' {
158+
Remove-Item -Force -ErrorAction SilentlyContinue -Path $script:cacheFilePath
159+
$out = & $script:discoverScript | ConvertFrom-Json
160+
$out.manifestPath | Should -Contain $adaptedManifestPath
161+
}
130162
}

0 commit comments

Comments
 (0)