-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathdsc_functions.tests.ps1
More file actions
514 lines (477 loc) · 22.4 KB
/
Copy pathdsc_functions.tests.ps1
File metadata and controls
514 lines (477 loc) · 22.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
Describe 'tests for function expressions' {
BeforeAll {
$env:DSC_TRACE_LEVEL = 'error'
}
AfterAll {
$env:DSC_TRACE_LEVEL = $null
}
It 'function works: <text>' -TestCases @(
@{ text = "[concat('a', 'b')]"; expected = 'ab' }
@{ text = "[concat('a', 'b', 'c')]"; expected = 'abc' }
@{ text = "[concat('a', concat('b', 'c'))]"; expected = 'abc' }
@{ text = "[base64('ab')]"; expected = 'YWI=' }
@{ text = "[base64(concat('a','b'))]"; expected = 'YWI=' }
@{ text = "[base64(base64(concat('a','b')))]"; expected = 'WVdJPQ==' }
) {
param($text, $expected)
$escapedText = $text -replace "'", "''"
$config_yaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: '$escapedText'
"@
$out = $config_yaml | dsc config get -f - | ConvertFrom-Json
$out.results[0].result.actualState.output | Should -Be $expected
}
It 'path(<path>) works' -TestCases @(
@{ path = "systemRoot(), 'a'"; expected = "$PSHOME$([System.IO.Path]::DirectorySeparatorChar)a" }
@{ path = "'a', 'b', 'c'"; expected = "a$([System.IO.Path]::DirectorySeparatorChar)b$([System.IO.Path]::DirectorySeparatorChar)c" }
) {
param($path, $expected)
$config_yaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: "[path($path)]"
"@
$out = $config_yaml | dsc config --system-root $PSHOME get -f - | ConvertFrom-Json
$out.results[0].result.actualState.output | Should -BeExactly $expected
}
It 'default systemRoot() is correct for the OS' {
$config_yaml = @'
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: "[systemRoot()]"
'@
$expected = if ($IsWindows) {
$env:SYSTEMDRIVE + '\'
} else {
'/'
}
$out = $config_yaml | dsc config get -f - | ConvertFrom-Json
$LASTEXITCODE | Should -Be 0
$out.results[0].result.actualState.output | Should -BeExactly $expected
}
It 'union function works for: <expression>' -TestCases @(
@{ expression = "[union(parameters('firstArray'), parameters('secondArray'))]"; expected = @('ab', 'cd', 'ef') }
@{ expression = "[union(parameters('firstObject'), parameters('secondObject'))]"; expected = [pscustomobject]@{ one = 'a'; two = 'c'; three = 'd' } }
@{ expression = "[union(parameters('secondArray'), parameters('secondArray'))]"; expected = @('cd', 'ef') }
@{ expression = "[union(parameters('secondObject'), parameters('secondObject'))]"; expected = [pscustomobject]@{ two = 'c'; three = 'd' } }
@{ expression = "[union(parameters('firstObject'), parameters('firstArray'))]"; isError = $true }
) {
param($expression, $expected, $isError)
$config_yaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
parameters:
firstObject:
type: object
defaultValue:
one: a
two: b
secondObject:
type: object
defaultValue:
two: c
three: d
firstArray:
type: array
defaultValue:
- ab
- cd
secondArray:
type: array
defaultValue:
- cd
- ef
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: "$expression"
"@
$out = dsc -l trace config get -i $config_yaml 2>$TestDrive/error.log | ConvertFrom-Json
if ($isError) {
$LASTEXITCODE | Should -Be 2 -Because (Get-Content $TestDrive/error.log -Raw)
(Get-Content $TestDrive/error.log -Raw) | Should -Match 'All arguments must either be arrays or objects'
} else {
$LASTEXITCODE | Should -Be 0 -Because (Get-Content $TestDrive/error.log -Raw)
($out.results[0].result.actualState.output | Out-String) | Should -BeExactly ($expected | Out-String)
}
}
It 'contain function works for: <expression>' -TestCases @(
@{ expression = "[contains(parameters('array'), 'a')]" ; expected = $true }
@{ expression = "[contains(parameters('array'), 2)]" ; expected = $false }
@{ expression = "[contains(parameters('array'), 1)]" ; expected = $true }
@{ expression = "[contains(parameters('array'), 'z')]" ; expected = $false }
@{ expression = "[contains(parameters('object'), 'a')]" ; expected = $true }
@{ expression = "[contains(parameters('object'), 'c')]" ; expected = $false }
@{ expression = "[contains(parameters('object'), 3)]" ; expected = $true }
@{ expression = "[contains(parameters('object'), parameters('object'))]" ; isError = $true }
@{ expression = "[contains(parameters('array'), parameters('array'))]" ; isError = $true }
@{ expression = "[contains(parameters('string'), 'not found')]" ; expected = $false }
@{ expression = "[contains(parameters('string'), 'hello')]" ; expected = $true }
@{ expression = "[contains(parameters('string'), 12)]" ; expected = $true }
) {
param($expression, $expected, $isError)
$config_yaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
parameters:
array:
type: array
defaultValue:
- a
- b
- 0
- 1
object:
type: object
defaultValue:
a: 1
b: 2
3: c
string:
type: string
defaultValue: 'hello 123 world!'
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: "$expression"
"@
$out = dsc -l trace config get -i $config_yaml 2>$TestDrive/error.log | ConvertFrom-Json
if ($isError) {
$LASTEXITCODE | Should -Be 2 -Because (Get-Content $TestDrive/error.log -Raw)
(Get-Content $TestDrive/error.log -Raw) | Should -Match 'accepted types are: String, Number'
} else {
$LASTEXITCODE | Should -Be 0 -Because (Get-Content $TestDrive/error.log -Raw)
($out.results[0].result.actualState.output | Out-String) | Should -BeExactly ($expected | Out-String)
}
}
It 'length function works for: <expression>' -TestCases @(
@{ expression = "[length(parameters('array'))]" ; expected = 3 }
@{ expression = "[length(parameters('object'))]" ; expected = 4 }
@{ expression = "[length(parameters('string'))]" ; expected = 12 }
@{ expression = "[length('')]"; expected = 0 }
) {
param($expression, $expected, $isError)
$config_yaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
parameters:
array:
type: array
defaultValue:
- a
- b
- c
object:
type: object
defaultValue:
one: a
two: b
three: c
four: d
string:
type: string
defaultValue: 'hello world!'
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: "$expression"
"@
$out = dsc -l trace config get -i $config_yaml 2>$TestDrive/error.log | ConvertFrom-Json
$LASTEXITCODE | Should -Be 0 -Because (Get-Content $TestDrive/error.log -Raw)
($out.results[0].result.actualState.output | Out-String) | Should -BeExactly ($expected | Out-String)
}
It 'empty function works for: <expression>' -TestCases @(
@{ expression = "[empty(parameters('array'))]" ; expected = $false }
@{ expression = "[empty(parameters('object'))]" ; expected = $false }
@{ expression = "[empty(parameters('string'))]" ; expected = $false }
@{ expression = "[empty(parameters('emptyArray'))]" ; expected = $true }
@{ expression = "[empty(parameters('emptyObject'))]" ; expected = $true }
@{ expression = "[empty('')]" ; expected = $true }
) {
param($expression, $expected)
$config_yaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
parameters:
array:
type: array
defaultValue:
- a
- b
- c
emptyArray:
type: array
defaultValue: []
object:
type: object
defaultValue:
one: a
two: b
three: c
emptyObject:
type: object
defaultValue: {}
string:
type: string
defaultValue: 'hello world!'
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: "$expression"
"@
$out = dsc -l trace config get -i $config_yaml 2>$TestDrive/error.log | ConvertFrom-Json
$LASTEXITCODE | Should -Be 0 -Because (Get-Content $TestDrive/error.log -Raw)
($out.results[0].result.actualState.output | Out-String) | Should -BeExactly ($expected | Out-String)
}
It 'utcNow function works for: utcNow(<format>)' -TestCases @(
@{ format = $null; regex = '^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}Z$' }
@{ format = "yyyy-MM-dd"; regex = '^\d{4}-\d{2}-\d{2}$' }
@{ format = "yyyy-MM-ddTHH"; regex = '^\d{4}-\d{2}-\d{2}T\d{2}$' }
@{ format = "yyyy-MM-ddTHHZ"; regex = '^\d{4}-\d{2}-\d{2}T\d{2}Z$' }
@{ format = "MMM dd, yyyy HH"; regex = '^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{2}, \d{4} \d{2}$' }
@{ format = "yy-MMMM-dddd tt H"; regex = '^\d{2}-(January|February|March|April|May|June|July|August|September|October|November|December)-(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday) (AM|PM) \d+$' }
@{ format = "MMM ddd zzz"; regex = '^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (Sun|Mon|Tue|Wed|Thu|Fri|Sat) \+00:00$' }
@{ format = "yy yyyy MM MMM MMMM"; regex = '^\d{2} \d{4} \d{2} (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (January|February|March|April|May|June|July|August|September|October|November|December)$' }
@{ format = "yyyy-MM-ddTHH:mm:ss"; regex = '^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$' }
) {
param($format, $regex)
if ($null -ne $format) {
$format = "'$format'"
}
$config_yaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
parameters:
test:
type: string
defaultValue: "[utcNow($format)]"
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: "[parameters('test')]"
"@
$out = dsc -l trace config get -i $config_yaml 2>$TestDrive/error.log
$LASTEXITCODE | Should -Be 0 -Because (Get-Content $TestDrive/error.log -Raw)
# ConvertFrom-Json will convert the date to a DateTime object, so we use regex to capture the string
$out -match '"output":"(?<date>.*?)"' | Should -BeTrue -Because "Output should contain a date"
$actual = $matches['date']
# compare against the regex
$actual | Should -Match $regex -Because "Output date '$actual' should match regex '$regex'"
}
It 'utcNow errors if used not as a parameter default' {
$config_yaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: "[utcNow()]"
"@
$out = dsc -l trace config get -i $config_yaml 2>$TestDrive/error.log | ConvertFrom-Json
$LASTEXITCODE | Should -Be 2 -Because (Get-Content $TestDrive/error.log -Raw)
$out | Should -BeNullOrEmpty -Because "Output should be null or empty"
(Get-Content $TestDrive/error.log -Raw) | Should -Match "The 'utcNow\(\)' function can only be used as a parameter default"
}
It 'uniqueString function works for: <expression>' -TestCases @(
@{ expression = "[uniqueString('a')]" ; expected = 'cfvwxu6sc4lqo' }
@{ expression = "[uniqueString('a', 'b', 'c')]" ; expected = 'bhw7m6t6ntwd6' }
@{ expression = "[uniqueString('a', 'b', 'c', 'd')]" ; expected = 'yxzg7ur4qetcy' }
) {
param($expression, $expected)
$config_yaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: "$expression"
"@
$out = dsc -l trace config get -i $config_yaml 2>$TestDrive/error.log | ConvertFrom-Json
$LASTEXITCODE | Should -Be 0 -Because (Get-Content $TestDrive/error.log -Raw)
$out.results[0].result.actualState.output | Should -BeExactly $expected
}
It 'string function works for: <expression>' -TestCases @(
@{ expression = "[string('hello')]"; expected = 'hello' }
@{ expression = "[string(123)]"; expected = '123' }
@{ expression = "[string(true)]"; expected = 'true' }
@{ expression = "[string(null())]"; expected = 'null' }
@{ expression = "[string(createArray('a', 'b'))]"; expected = '["a","b"]' }
@{ expression = "[string(createObject('a', 1))]"; expected = '{"a":1}' }
) {
param($expression, $expected)
$config_yaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: "$expression"
"@
$out = dsc -l trace config get -i $config_yaml 2>$TestDrive/error.log | ConvertFrom-Json
$LASTEXITCODE | Should -Be 0 -Because (Get-Content $TestDrive/error.log -Raw)
($out.results[0].result.actualState.output | Out-String) | Should -BeExactly ($expected | Out-String)
}
It 'array function works for: <expression>' -TestCases @(
@{ expression = "[array('hello')]"; expected = @('hello') }
@{ expression = "[array(42)]"; expected = @(42) }
@{ expression = "[array(createObject('key', 'value'))]"; expected = @([pscustomobject]@{ key = 'value' }) }
@{ expression = "[array(createArray('a', 'b'))]"; expected = @(@('a', 'b')) }
) {
param($expression, $expected)
$config_yaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: "$expression"
"@
$out = dsc -l trace config get -i $config_yaml 2>$TestDrive/error.log | ConvertFrom-Json
$LASTEXITCODE | Should -Be 0 -Because (Get-Content $TestDrive/error.log -Raw)
($out.results[0].result.actualState.output | Out-String) | Should -BeExactly ($expected | Out-String)
}
It 'first function works for: <expression>' -TestCases @(
@{ expression = "[first(createArray('hello', 'world'))]"; expected = 'hello' }
@{ expression = "[first(createArray(1, 2, 3))]"; expected = 1 }
@{ expression = "[first('hello')]"; expected = 'h' }
@{ expression = "[first('a')]"; expected = 'a' }
@{ expression = "[first(array('mixed'))]"; expected = 'mixed' }
) {
param($expression, $expected)
$config_yaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: "$expression"
"@
$out = dsc -l trace config get -i $config_yaml 2>$TestDrive/error.log | ConvertFrom-Json
$LASTEXITCODE | Should -Be 0 -Because (Get-Content $TestDrive/error.log -Raw)
($out.results[0].result.actualState.output | Out-String) | Should -BeExactly ($expected | Out-String)
}
It 'indexOf function works for: <expression>' -TestCases @(
@{ expression = "[indexOf(createArray('apple', 'banana', 'cherry'), 'banana')]"; expected = 1 }
@{ expression = "[indexOf(createArray('apple', 'banana', 'cherry'), 'cherry')]"; expected = 2 }
@{ expression = "[indexOf(createArray(10, 20, 30), 20)]"; expected = 1 }
@{ expression = "[indexOf(createArray('a', 'b', 'a', 'c'), 'a')]"; expected = 0 }
@{ expression = "[indexOf(createArray('apple', 'banana'), 'orange')]"; expected = -1 }
@{ expression = "[indexOf(createArray('Apple', 'Banana'), 'apple')]"; expected = -1 }
@{ expression = "[indexOf(createArray(), 'test')]"; expected = -1 }
@{ expression = "[indexOf(createArray(createArray('a', 'b'), createArray('c', 'd')), createArray('c', 'd'))]"; expected = 1 }
) {
param($expression, $expected)
$config_yaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: "$expression"
"@
$out = dsc -l trace config get -i $config_yaml 2>$TestDrive/error.log | ConvertFrom-Json
$LASTEXITCODE | Should -Be 0 -Because (Get-Content $TestDrive/error.log -Raw)
($out.results[0].result.actualState.output | Out-String) | Should -BeExactly ($expected | Out-String)
}
It 'join function works for: <expression>' -TestCases @(
@{ expression = "[join(createArray('a','b','c'), '-')]"; expected = 'a-b-c' }
@{ expression = "[join(createArray(), '-')]"; expected = '' }
@{ expression = "[join(createArray(1,2,3), ',')]"; expected = '1,2,3' }
) {
param($expression, $expected)
$config_yaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: "$expression"
"@
$out = dsc -l trace config get -i $config_yaml 2>$TestDrive/error.log | ConvertFrom-Json
$LASTEXITCODE | Should -Be 0 -Because (Get-Content $TestDrive/error.log -Raw)
($out.results[0].result.actualState.output | Out-String) | Should -BeExactly ($expected | Out-String)
}
It 'skip function works for: <expression>' -TestCases @(
@{ expression = "[skip(createArray('a','b','c','d'), 2)]"; expected = @('c', 'd') }
@{ expression = "[skip('hello', 2)]"; expected = 'llo' }
@{ expression = "[skip(createArray('a','b'), 0)]"; expected = @('a', 'b') }
@{ expression = "[skip('abc', 0)]"; expected = 'abc' }
@{ expression = "[skip(createArray('a','b'), 5)]"; expected = @() }
@{ expression = "[skip('', 1)]"; expected = '' }
# Negative counts are treated as zero
@{ expression = "[skip(createArray('x','y'), -3)]"; expected = @('x', 'y') }
@{ expression = "[skip('xy', -1)]"; expected = 'xy' }
) {
param($expression, $expected)
$config_yaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: "$expression"
"@
$out = dsc -l trace config get -i $config_yaml 2>$TestDrive/error.log | ConvertFrom-Json
$LASTEXITCODE | Should -Be 0 -Because (Get-Content $TestDrive/error.log -Raw)
($out.results[0].result.actualState.output | Out-String) | Should -BeExactly ($expected | Out-String)
}
It 'lastIndexOf function works for: <expression>' -TestCases @(
@{ expression = "[lastIndexOf(createArray('a', 'b', 'a', 'c'), 'a')]"; expected = 2 }
@{ expression = "[lastIndexOf(createArray(10, 20, 30, 20), 20)]"; expected = 3 }
@{ expression = "[lastIndexOf(createArray('Apple', 'Banana'), 'apple')]"; expected = -1 }
@{ expression = "[lastIndexOf(createArray(createArray('a','b'), createArray('c','d'), createArray('a','b')), createArray('a','b'))]"; expected = 2 }
@{ expression = "[lastIndexOf(createArray(createObject('name','John'), createObject('name','Jane'), createObject('name','John')), createObject('name','John'))]"; expected = 2 }
@{ expression = "[lastIndexOf(createArray(), 'test')]"; expected = -1 }
# Objects are compared by deep equality: same keys and values are equal, regardless of property order.
# Both createObject('a',1,'b',2) and createObject('b',2,'a',1) are considered equal.
# Therefore, lastIndexOf returns 1 (the last position where an equal object occurs).
@{ expression = "[lastIndexOf(createArray(createObject('a',1,'b',2), createObject('b',2,'a',1)), createObject('a',1,'b',2))]"; expected = 1 }
@{ expression = "[lastIndexOf(createArray('1','2','3'), 1)]"; expected = -1 }
@{ expression = "[lastIndexOf(createArray(1,2,3), '1')]"; expected = -1 }
) {
param($expression, $expected)
$config_yaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: "$expression"
"@
$out = dsc -l trace config get -i $config_yaml 2>$TestDrive/error.log | ConvertFrom-Json
$LASTEXITCODE | Should -Be 0 -Because (Get-Content $TestDrive/error.log -Raw)
($out.results[0].result.actualState.output | Out-String) | Should -BeExactly ($expected | Out-String)
}
It 'context function works' {
$config_yaml = @"
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: "[context()]"
"@
$out = dsc -l trace config get -i $config_yaml 2>$TestDrive/error.log | ConvertFrom-Json
$LASTEXITCODE | Should -Be 0 -Because (Get-Content $TestDrive/error.log -Raw)
$context = $out.results[0].result.actualState.output
$os = osinfo | ConvertFrom-Json
$context.os.family | Should -BeExactly $os.family
$context.os.version | Should -BeExactly $os.version
$context.os.bitness | Should -BeExactly $os.bitness
$context.os.architecture | Should -BeExactly $os.architecture
$context.security | Should -BeExactly $out.metadata.'Microsoft.DSC'.securityContext
}
}