Skip to content

Commit c77feb5

Browse files
committed
fix test to use regex instead of -DateKind which was added in PS7.5
1 parent 2c26ad1 commit c77feb5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

dsc/tests/dsc_functions.tests.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,11 @@ Describe 'tests for function expressions' {
275275
properties:
276276
output: "[parameters('test')]"
277277
"@
278-
$out = dsc -l trace config get -i $config_yaml 2>$TestDrive/error.log | ConvertFrom-Json -DateKind String
278+
$out = dsc -l trace config get -i $config_yaml 2>$TestDrive/error.log
279279
$LASTEXITCODE | Should -Be 0 -Because (Get-Content $TestDrive/error.log -Raw)
280-
$actual = $out.results[0].result.actualState.output
280+
# ConvertFrom-Json will convert the date to a DateTime object, so we use regex to capture the string
281+
$out -match '"output":"(?<date>.*?)"' | Should -BeTrue -Because "Output should contain a date"
282+
$actual = $matches['date']
281283
# since the datetimes might slightly differ, we remove the seconds and milliseconds
282284
$expected = $expected -replace ':\d+\.\d+Z$', 'Z'
283285
$actual = $actual -replace ':\d+\.\d+Z$', 'Z'

0 commit comments

Comments
 (0)