Skip to content

Commit c57cf42

Browse files
Steve Lee (POWERSHELL HE/HIM) (from Dev Box)SteveL-MSFT
authored andcommitted
fix tests to explicit read from stdin
1 parent c077254 commit c57cf42

3 files changed

Lines changed: 58 additions & 58 deletions

File tree

resources/WindowsUpdate/tests/windowsupdate_export.tests.ps1

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Describe 'Windows Update Export operation tests' {
88

99
Context 'Export operation' {
1010
It 'should return UpdateList with array of updates' -Skip:(!$IsWindows) {
11-
$out = '{"updates":[{}]}' | dsc resource export -r $resourceType -o json 2>&1
11+
$out = '{"updates":[{}]}' | dsc resource export -r $resourceType -f - -o json 2>&1
1212

1313
$LASTEXITCODE | Should -Be 0
1414
$config = $out | ConvertFrom-Json
@@ -18,7 +18,7 @@ Describe 'Windows Update Export operation tests' {
1818
}
1919

2020
It 'should work without input filter' -Skip:(!$IsWindows) {
21-
$out = '' | dsc resource export -r $resourceType -o json 2>&1
21+
$out = dsc resource export -r $resourceType -o json 2>&1
2222

2323
$LASTEXITCODE | Should -Be 0
2424
$config = $out | ConvertFrom-Json
@@ -28,7 +28,7 @@ Describe 'Windows Update Export operation tests' {
2828

2929
It 'should filter by isInstalled=true' -Skip:(!$IsWindows) {
3030
$json = '{"updates":[{"isInstalled": true}]}'
31-
$out = $json | dsc resource export -r $resourceType -o json 2>&1
31+
$out = $json | dsc resource export -r $resourceType -f - -o json 2>&1
3232

3333
$LASTEXITCODE | Should -Be 0
3434
$config = $out | ConvertFrom-Json
@@ -42,7 +42,7 @@ Describe 'Windows Update Export operation tests' {
4242

4343
It 'should filter by isInstalled=false' -Skip:(!$IsWindows) {
4444
$json = '{"updates":[{"isInstalled": false}]}'
45-
$out = $json | dsc resource export -r $resourceType -o json 2>&1
45+
$out = $json | dsc resource export -r $resourceType -f - -o json 2>&1
4646

4747
$LASTEXITCODE | Should -Be 0
4848
$config = $out | ConvertFrom-Json
@@ -56,7 +56,7 @@ Describe 'Windows Update Export operation tests' {
5656

5757
It 'should filter by title with wildcard in middle' -Skip:(!$IsWindows) {
5858
$json = '{"updates":[{"title": "*Windows*"}]}'
59-
$out = $json | dsc resource export -r $resourceType -o json 2>&1
59+
$out = $json | dsc resource export -r $resourceType -f - -o json 2>&1
6060

6161
if ($LASTEXITCODE -eq 0) {
6262
$config = $out | ConvertFrom-Json
@@ -70,7 +70,7 @@ Describe 'Windows Update Export operation tests' {
7070
}
7171

7272
It 'should return proper structure for each update' -Skip:(!$IsWindows) {
73-
$out = '{"updates":[{}]}' | dsc resource export -r $resourceType -o json 2>&1
73+
$out = '{"updates":[{}]}' | dsc resource export -r $resourceType -f - -o json 2>&1
7474

7575
$LASTEXITCODE | Should -Be 0
7676
$config = $out | ConvertFrom-Json
@@ -92,7 +92,7 @@ Describe 'Windows Update Export operation tests' {
9292

9393
It 'should fail when wildcard filter has no matches' -Skip:(!$IsWindows) {
9494
$json = '{"updates":[{"title": "ThisUpdateShouldNeverExist99999*"}]}'
95-
$stderr = $json | dsc resource export -r $resourceType -o json 2>&1
95+
$stderr = $json | dsc resource export -r $resourceType -f - -o json 2>&1
9696

9797
# Should fail because the filter has criteria but no matches
9898
$LASTEXITCODE | Should -Not -Be 0
@@ -111,7 +111,7 @@ Describe 'Windows Update Export operation tests' {
111111
}
112112
)
113113
} | ConvertTo-Json -Depth 10 -Compress
114-
$stderr = $json | dsc resource export -r $resourceType 2>&1
114+
$stderr = $json | dsc resource export -r $resourceType -f - 2>&1
115115

116116
# Should fail because the filter has criteria but no matches
117117
$LASTEXITCODE | Should -Not -Be 0
@@ -128,7 +128,7 @@ Describe 'Windows Update Export operation tests' {
128128
@{}
129129
)
130130
} | ConvertTo-Json -Depth 10 -Compress
131-
$out = $json | dsc resource export -r $resourceType -o json 2>&1
131+
$out = $json | dsc resource export -r $resourceType -f - -o json 2>&1
132132

133133
$LASTEXITCODE | Should -Be 0
134134
$config = $out | ConvertFrom-Json
@@ -138,7 +138,7 @@ Describe 'Windows Update Export operation tests' {
138138

139139
It 'should fail if any filter with criteria has no matches' -Skip:(!$IsWindows) {
140140
# Get an actual update
141-
$allOut = '{"updates":[{}]}' | dsc resource export -r $resourceType -o json 2>&1
141+
$allOut = '{"updates":[{}]}' | dsc resource export -r $resourceType -f - -o json 2>&1
142142

143143
if ($LASTEXITCODE -eq 0) {
144144
$allConfig = $allOut | ConvertFrom-Json
@@ -157,7 +157,7 @@ Describe 'Windows Update Export operation tests' {
157157
}
158158
)
159159
} | ConvertTo-Json -Depth 10 -Compress
160-
$stderr = $json | dsc resource export -r $resourceType 2>&1
160+
$stderr = $json | dsc resource export -r $resourceType -f - 2>&1
161161

162162
# Should fail because second filter has no matches
163163
$LASTEXITCODE | Should -Not -Be 0
@@ -171,7 +171,7 @@ Describe 'Windows Update Export operation tests' {
171171

172172
It 'should return results when all filters find matches' -Skip:(!$IsWindows) {
173173
# Get actual updates
174-
$allOut = '{"updates":[{}]}' | dsc resource export -r $resourceType -o json 2>&1
174+
$allOut = '{"updates":[{}]}' | dsc resource export -r $resourceType -f - -o json 2>&1
175175

176176
if ($LASTEXITCODE -eq 0) {
177177
$allConfig = $allOut | ConvertFrom-Json
@@ -190,7 +190,7 @@ Describe 'Windows Update Export operation tests' {
190190
}
191191
)
192192
} | ConvertTo-Json -Depth 10 -Compress
193-
$out = $json | dsc resource export -r $resourceType -o json 2>&1
193+
$out = $json | dsc resource export -r $resourceType -f - -o json 2>&1
194194

195195
$LASTEXITCODE | Should -Be 0
196196
$config = $out | ConvertFrom-Json
@@ -205,7 +205,7 @@ Describe 'Windows Update Export operation tests' {
205205

206206
It 'should filter by msrcSeverity' -Skip:(!$IsWindows) {
207207
$json = '{"updates":[{"msrcSeverity": "Critical"}]}'
208-
$out = $json | dsc resource export -r $resourceType -o json 2>&1
208+
$out = $json | dsc resource export -r $resourceType -f - -o json 2>&1
209209

210210
if ($LASTEXITCODE -eq 0) {
211211
$config = $out | ConvertFrom-Json
@@ -220,7 +220,7 @@ Describe 'Windows Update Export operation tests' {
220220

221221
It 'should filter by updateType Software' -Skip:(!$IsWindows) {
222222
$json = '{"updates":[{"updateType": "Software"}]}'
223-
$out = $json | dsc resource export -r $resourceType -o json 2>&1
223+
$out = $json | dsc resource export -r $resourceType -f - -o json 2>&1
224224

225225
if ($LASTEXITCODE -eq 0) {
226226
$config = $out | ConvertFrom-Json
@@ -235,7 +235,7 @@ Describe 'Windows Update Export operation tests' {
235235

236236
It 'should support OR logic with multiple filters in array' -Skip:(!$IsWindows) {
237237
# Get some updates to use as filters
238-
$allOut = '{"updates":[{}]}' | dsc resource export -r $resourceType -o json 2>&1
238+
$allOut = '{"updates":[{}]}' | dsc resource export -r $resourceType -f - -o json 2>&1
239239

240240
if ($LASTEXITCODE -eq 0) {
241241
$allConfig = $allOut | ConvertFrom-Json
@@ -245,7 +245,7 @@ Describe 'Windows Update Export operation tests' {
245245
$id1 = $allResult.updates[0].id
246246
$id2 = $allResult.updates[1].id
247247
$json = "{`"updates`":[{`"id`": `"$id1`"}, {`"id`": `"$id2`"}]}"
248-
$out = $json | dsc resource export -r $resourceType -o json 2>&1
248+
$out = $json | dsc resource export -r $resourceType -f - -o json 2>&1
249249

250250
$LASTEXITCODE | Should -Be 0
251251
$config = $out | ConvertFrom-Json
@@ -267,7 +267,7 @@ Describe 'Windows Update Export operation tests' {
267267
It 'should support AND logic within single filter object' -Skip:(!$IsWindows) {
268268
# Multiple properties in one filter = AND logic
269269
$json = '{"updates":[{"isInstalled": true, "updateType": "Software"}]}'
270-
$out = $json | dsc resource export -r $resourceType -o json 2>&1
270+
$out = $json | dsc resource export -r $resourceType -f - -o json 2>&1
271271

272272
if ($LASTEXITCODE -eq 0) {
273273
$config = $out | ConvertFrom-Json
@@ -284,7 +284,7 @@ Describe 'Windows Update Export operation tests' {
284284

285285
It 'should not return duplicates when multiple filters match same update' -Skip:(!$IsWindows) {
286286
# Get an update with known properties
287-
$allOut = '{"updates":[{}]}' | dsc resource export -r $resourceType -o json 2>&1
287+
$allOut = '{"updates":[{}]}' | dsc resource export -r $resourceType -f - -o json 2>&1
288288

289289
if ($LASTEXITCODE -eq 0) {
290290
$allConfig = $allOut | ConvertFrom-Json
@@ -294,7 +294,7 @@ Describe 'Windows Update Export operation tests' {
294294
# Use the same ID in both filters - this should only return one update
295295
# Even though technically both filters specify the same criteria
296296
$json = "{`"updates`":[{`"id`": `"$($testUpdate.id)`"}, {`"id`": `"$($testUpdate.id)`"}]}"
297-
$out = $json | dsc resource export -r $resourceType -o json 2>&1
297+
$out = $json | dsc resource export -r $resourceType -f - -o json 2>&1
298298

299299
$LASTEXITCODE | Should -Be 0 -Because $out
300300
$config = $out | ConvertFrom-Json
@@ -308,7 +308,7 @@ Describe 'Windows Update Export operation tests' {
308308
}
309309

310310
It 'should return installationBehavior property when present' -Skip:(!$IsWindows) {
311-
$out = '{"updates":[{}]}' | dsc resource export -r $resourceType -o json 2>&1
311+
$out = '{"updates":[{}]}' | dsc resource export -r $resourceType -f - -o json 2>&1
312312

313313
$LASTEXITCODE | Should -Be 0
314314
$config = $out | ConvertFrom-Json
@@ -326,7 +326,7 @@ Describe 'Windows Update Export operation tests' {
326326
}
327327

328328
It 'should return valid installationBehavior enum values for all updates' -Skip:(!$IsWindows) {
329-
$out = '{"updates":[{}]}' | dsc resource export -r $resourceType -o json 2>&1
329+
$out = '{"updates":[{}]}' | dsc resource export -r $resourceType -f - -o json 2>&1
330330

331331
$LASTEXITCODE | Should -Be 0
332332
$config = $out | ConvertFrom-Json

0 commit comments

Comments
 (0)