@@ -74,7 +74,7 @@ Describe 'tests for resource discovery' {
7474 $resources.Count | Should - Be 0
7575 }
7676
77- It ' warns on invalid semver' {
77+ It ' info on invalid semver' {
7878 $manifest = @'
7979 {
8080 "$schema": "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json",
@@ -94,9 +94,8 @@ Describe 'tests for resource discovery' {
9494 try {
9595 $env: DSC_RESOURCE_PATH = $testdrive
9696 Set-Content - Path " $testdrive /test.dsc.resource.json" - Value $manifest
97- $out = dsc resource list 2>&1
98- write-verbose - verbose ($out | Out-String )
99- $out | Should -Match ' WARN.*?Validation.*?invalid version' - Because ($out | Out-String )
97+ $out = dsc - l info resource list 2>&1 | Out-String
98+ $out | Should - BeLike ' *INFO*Validation*invalid version*' - Because ($out | Out-String )
10099 }
101100 finally {
102101 $env: DSC_RESOURCE_PATH = $oldPath
@@ -302,4 +301,32 @@ Describe 'tests for resource discovery' {
302301 $env: DSC_RESOURCE_PATH = $null
303302 }
304303 }
304+
305+ It ' Invalid resource manifest will generate info message' {
306+ $invalidManifest = @'
307+ {
308+ "$schema": "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json",
309+ "type": "Test/InvalidManifest",
310+ "version": "0.1.0",
311+ "get": {
312+ "executable": "dsctest",
313+ "unexpectedField": "This field is not expected in the get section and should be ignored by the discovery process"
314+ },
315+ "newProperty": "This property is not expected in the manifest and should be ignored by the discovery process"
316+ }
317+ '@
318+ Set-Content - Path " $testdrive /test.dsc.resource.json" - Value $invalidManifest
319+ $oldPath = $env: DSC_RESOURCE_PATH
320+ try {
321+ $env: DSC_RESOURCE_PATH = $testdrive + [System.IO.Path ]::PathSeparator + $env: PATH
322+
323+ $out = dsc - l info resource list ' Test/InvalidManifest' 2> " $testdrive /error.txt" | ConvertFrom-Json
324+ $LASTEXITCODE | Should - Be 0
325+ $out | Should - BeNullOrEmpty - Because (Get-Content - Raw - Path " $testdrive /error.txt" )
326+ $errorLog = Get-Content - Raw - Path " $testdrive /error.txt"
327+ $errorLog | Should - BeLike " *INFO Failed to load manifest: Manifest: Invalid manifest for resource '*test.dsc.resource.json'*" - Because $errorLog
328+ } finally {
329+ $env: DSC_RESOURCE_PATH = $oldPath
330+ }
331+ }
305332}
0 commit comments