Skip to content

Commit

Permalink
update if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
tgauth committed Feb 8, 2024
1 parent a693f3d commit bd0bc51
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 16 additions & 0 deletions dsc/tests/dsc_discovery.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,20 @@ Describe 'tests for resource discovery' {
$resources.Count | Should -Be 1
$resources.type | Should -BeExactly 'DSC/TestYamlResource'
}

It 'does not support discovering a file with an extension that is not json or yaml' {
param($extension)

$resourceInput = @'
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/bundled/resource/manifest.json
type: DSC/TestYamlResource
version: 0.1.0
get:
executable: dsc
'@

Set-Content -Path "$testdrive/test.dsc.resource.txt" -Value $resourceInput
$resources = dsc resource list | ConvertFrom-Json
$resources.Count | Should -Be 0
}
}
6 changes: 3 additions & 3 deletions dsc_lib/src/discovery/command_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ impl CommandDiscovery {
if path.is_file() {
let file_name = path.file_name().unwrap().to_str().unwrap();
let file_name_lowercase = file_name.to_lowercase();
if file_name_lowercase.ends_with(".dsc.resource.json") |
file_name_lowercase.ends_with(".dsc.resource.yaml") |
file_name_lowercase.ends_with(".dsc.resource.yml") {
if file_name_lowercase.ends_with(".dsc.resource.json") ||
file_name_lowercase.ends_with(".dsc.resource.yaml") ||
file_name_lowercase.ends_with(".dsc.resource.yml") {
let resource = match load_manifest(&path)
{
Ok(r) => r,
Expand Down

0 comments on commit bd0bc51

Please sign in to comment.