Skip to content

Commit 385cfac

Browse files
authored
Merge pull request #385 from SteveL-MSFT/arg-object
Refactor arguments to command resources an mixed strings and objects for extensibility
2 parents 079a90f + bff600e commit 385cfac

18 files changed

+215
-224
lines changed

dsc/assertion.dsc.resource.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"args": [
6161
"config",
6262
"validate"
63-
]
63+
],
64+
"input": "stdin"
6465
}
6566
}

dsc/group.dsc.resource.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"args": [
4949
"config",
5050
"validate"
51-
]
51+
],
52+
"input": "stdin"
5253
}
5354
}

dsc/parallel.dsc.resource.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"args": [
5252
"config",
5353
"validate"
54-
]
54+
],
55+
"input": "stdin"
5556
}
5657
}

dsc/tests/dsc_args.tests.ps1

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,20 @@ Describe 'config argument tests' {
5454
$env:DSC_RESOURCE_PATH = $oldPath
5555
}
5656

57-
It 'input is <type>' -Skip:(!$IsWindows) -TestCases @(
57+
It 'input is <type>' -TestCases @(
5858
@{ type = 'yaml'; text = @'
59-
keyPath: HKLM\Software\Microsoft\Windows NT\CurrentVersion
60-
valueName: ProductName
59+
output: Hello There
6160
'@ }
6261
@{ type = 'json'; text = @'
6362
{
64-
"keyPath": "HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion",
65-
"valueName": "ProductName"
63+
"output": "Hello There"
6664
}
6765
'@ }
6866
) {
6967
param($text)
70-
$output = $text | dsc resource get -r Microsoft.Windows/Registry
68+
$output = $text | dsc resource get -r Test/Echo
7169
$output = $output | ConvertFrom-Json
72-
$output.actualState.keyPath | Should -BeExactly 'HKLM\Software\Microsoft\Windows NT\CurrentVersion'
73-
$output.actualState.valueName | Should -BeExactly 'ProductName'
74-
$output.actualState.valueData.String | Should -Match 'Windows .*'
70+
$output.actualState.output | Should -BeExactly 'Hello There'
7571
}
7672

7773
It '--format <format> is used even when redirected' -TestCases @(

dsc/tests/dsc_discovery.tests.ps1

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,14 @@ Describe 'tests for resource discovery' {
7272
$manifest = @'
7373
{
7474
"$schema": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/bundled/resource/manifest.json",
75-
"type": "Test/Echo",
75+
"type": "Test/InvalidSemver",
7676
"version": "1.1.0..1",
7777
"get": {
78-
"executable": "dsctest",
79-
"args": [
80-
"echo",
81-
"--input",
82-
"{json}"
83-
],
84-
"input": {
85-
"arg": "{json}"
86-
}
78+
"executable": "dsctest"
8779
},
8880
"schema": {
8981
"command": {
90-
"executable": "dsctest",
91-
"args": [
92-
"schema",
93-
"-s",
94-
"echo"
95-
]
82+
"executable": "dsctest"
9683
}
9784
}
9885
}
@@ -102,6 +89,7 @@ Describe 'tests for resource discovery' {
10289
$env:DSC_RESOURCE_PATH = $testdrive
10390
Set-Content -Path "$testdrive/test.dsc.resource.json" -Value $manifest
10491
$out = dsc resource list 2>&1
92+
write-verbose -verbose ($out | Out-String)
10593
$out | Should -Match 'WARN.*?Validation.*?Invalid manifest.*?version'
10694
}
10795
finally {

0 commit comments

Comments
 (0)