File tree 3 files changed +46
-0
lines changed
3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 19
19
" json" ,
20
20
" set"
21
21
],
22
+ "implementsPretest" : true ,
22
23
"input" : " stdin" ,
23
24
"return" : " state"
24
25
},
Original file line number Diff line number Diff line change @@ -35,4 +35,24 @@ Describe 'tests for runcommandonset get' {
35
35
' { "arguments": "foo" }' | dsc resource get - r Microsoft.DSC.Transitional/ RunCommandOnSet -f -
36
36
$LASTEXITCODE | Should - Be 2
37
37
}
38
+
39
+ It ' Input provided via configuration doc' {
40
+ $config_yaml = @"
41
+ `$ schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
42
+ resources:
43
+ - name: get
44
+ type: Microsoft.DSC.Transitional/RunCommandOnSet
45
+ properties:
46
+ executable: foo
47
+ arguments:
48
+ - "bar"
49
+ "@
50
+ $out = $config_yaml | dsc config get -f - | ConvertFrom-Json
51
+ $LASTEXITCODE | Should - Be 0
52
+ $out.hadErrors | Should - BeFalse
53
+ $out.results.Count | Should - Be 1
54
+ $out.results [0 ].type | Should - BeExactly ' Microsoft.DSC.Transitional/RunCommandOnSet'
55
+ $out.results [0 ].result.actualState.executable | Should - BeExactly ' foo'
56
+ $out.results [0 ].result.actualState.arguments[0 ] | Should - BeExactly ' bar'
57
+ }
38
58
}
Original file line number Diff line number Diff line change @@ -85,4 +85,29 @@ Describe 'tests for runcommandonset set' {
85
85
$actual | Should - BeLike " *$expected_logging *"
86
86
$LASTEXITCODE | Should - Be 2
87
87
}
88
+
89
+ It ' Input provided via configuration doc' {
90
+ $command = " Write-Output Hello | Out-File " + $TestDrive + " /output.txt" + " -Append"
91
+ $config_yaml = @"
92
+ `$ schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
93
+ resources:
94
+ - name: set
95
+ type: Microsoft.DSC.Transitional/RunCommandOnSet
96
+ properties:
97
+ executable: pwsh
98
+ arguments:
99
+ - -Command
100
+ - $command
101
+ "@
102
+ $out = $config_yaml | dsc config set -f - | ConvertFrom-Json
103
+ $LASTEXITCODE | Should - Be 0
104
+ $out.hadErrors | Should - BeFalse
105
+ $out.results.Count | Should - Be 1
106
+ $out.results [0 ].type | Should - BeExactly ' Microsoft.DSC.Transitional/RunCommandOnSet'
107
+ $out.results [0 ].result.afterState.executable | Should - BeExactly ' pwsh'
108
+ $out.results [0 ].result.afterState.arguments[0 ] | Should - BeExactly ' -Command'
109
+ Get-Content $TestDrive / output.txt | Should - BeExactly ' Hello'
110
+ $out = $config_yaml | dsc config set -f - | ConvertFrom-Json
111
+ Get-Content $TestDrive / output.txt | Should - BeExactly @ (' Hello' , ' Hello' )
112
+ }
88
113
}
You can’t perform that action at this time.
0 commit comments