Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor arguments to command resources an mixed strings and objects for extensibility #385

Merged
merged 10 commits into from
Apr 13, 2024
Merged
3 changes: 2 additions & 1 deletion dsc/assertion.dsc.resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"args": [
"config",
"validate"
]
],
"input": "stdin"
}
}
3 changes: 2 additions & 1 deletion dsc/group.dsc.resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"args": [
"config",
"validate"
]
],
"input": "stdin"
}
}
3 changes: 2 additions & 1 deletion dsc/parallel.dsc.resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"args": [
"config",
"validate"
]
],
"input": "stdin"
}
}
14 changes: 5 additions & 9 deletions dsc/tests/dsc_args.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,20 @@ Describe 'config argument tests' {
$env:DSC_RESOURCE_PATH = $oldPath
}

It 'input is <type>' -Skip:(!$IsWindows) -TestCases @(
It 'input is <type>' -TestCases @(
@{ type = 'yaml'; text = @'
keyPath: HKLM\Software\Microsoft\Windows NT\CurrentVersion
valueName: ProductName
output: Hello There
'@ }
@{ type = 'json'; text = @'
{
"keyPath": "HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion",
"valueName": "ProductName"
"output": "Hello There"
}
'@ }
) {
param($text)
$output = $text | dsc resource get -r Microsoft.Windows/Registry
$output = $text | dsc resource get -r Test/Echo
$output = $output | ConvertFrom-Json
$output.actualState.keyPath | Should -BeExactly 'HKLM\Software\Microsoft\Windows NT\CurrentVersion'
$output.actualState.valueName | Should -BeExactly 'ProductName'
$output.actualState.valueData.String | Should -Match 'Windows .*'
$output.actualState.output | Should -BeExactly 'Hello There'
}

It '--format <format> is used even when redirected' -TestCases @(
Expand Down
20 changes: 4 additions & 16 deletions dsc/tests/dsc_discovery.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,14 @@ Describe 'tests for resource discovery' {
$manifest = @'
{
"$schema": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/bundled/resource/manifest.json",
"type": "Test/Echo",
"type": "Test/InvalidSemver",
"version": "1.1.0..1",
"get": {
"executable": "dsctest",
"args": [
"echo",
"--input",
"{json}"
],
"input": {
"arg": "{json}"
}
"executable": "dsctest"
},
"schema": {
"command": {
"executable": "dsctest",
"args": [
"schema",
"-s",
"echo"
]
"executable": "dsctest"
}
}
}
Expand All @@ -102,6 +89,7 @@ Describe 'tests for resource discovery' {
$env:DSC_RESOURCE_PATH = $testdrive
Set-Content -Path "$testdrive/test.dsc.resource.json" -Value $manifest
$out = dsc resource list 2>&1
write-verbose -verbose ($out | Out-String)
$out | Should -Match 'WARN.*?Validation.*?Invalid manifest.*?version'
}
finally {
Expand Down
Loading
Loading