Skip to content

Commit bd0bc51

Browse files
committed
update if statement
1 parent a693f3d commit bd0bc51

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

dsc/tests/dsc_discovery.tests.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,20 @@ Describe 'tests for resource discovery' {
5151
$resources.Count | Should -Be 1
5252
$resources.type | Should -BeExactly 'DSC/TestYamlResource'
5353
}
54+
55+
It 'does not support discovering a file with an extension that is not json or yaml' {
56+
param($extension)
57+
58+
$resourceInput = @'
59+
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/bundled/resource/manifest.json
60+
type: DSC/TestYamlResource
61+
version: 0.1.0
62+
get:
63+
executable: dsc
64+
'@
65+
66+
Set-Content -Path "$testdrive/test.dsc.resource.txt" -Value $resourceInput
67+
$resources = dsc resource list | ConvertFrom-Json
68+
$resources.Count | Should -Be 0
69+
}
5470
}

dsc_lib/src/discovery/command_discovery.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ impl CommandDiscovery {
5252
if path.is_file() {
5353
let file_name = path.file_name().unwrap().to_str().unwrap();
5454
let file_name_lowercase = file_name.to_lowercase();
55-
if file_name_lowercase.ends_with(".dsc.resource.json") |
56-
file_name_lowercase.ends_with(".dsc.resource.yaml") |
57-
file_name_lowercase.ends_with(".dsc.resource.yml") {
55+
if file_name_lowercase.ends_with(".dsc.resource.json") ||
56+
file_name_lowercase.ends_with(".dsc.resource.yaml") ||
57+
file_name_lowercase.ends_with(".dsc.resource.yml") {
5858
let resource = match load_manifest(&path)
5959
{
6060
Ok(r) => r,

0 commit comments

Comments
 (0)