Skip to content

Commit 04c0af3

Browse files
TylerLeonhardtdaxian-dbw
authored andcommitted
Fix a test by making it more reliable (#122)
Formatting tables is different in pwsh 6.2-preview.3. We can no longer be sure that the last 2 items in a format-table string are new lines. Now we walk backwards until we hit the last not white-space line.
1 parent bf4ba5a commit 04c0af3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/Unit/Modules/Microsoft.Azure.Functions.PowerShellWorker.Tests.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,13 @@ Describe 'Azure Functions PowerShell Langauge Worker Helper Module Tests' {
200200

201201
$outStringResults = Write-TestObject | Out-String -Stream
202202
$ps.Streams.Information.Count | Should -BeExactly ($outStringResults.Count + 1)
203-
$countWithoutTrailingNewLines = $outStringResults.Count - 2
204-
for ($i = 0; $i -lt $countWithoutTrailingNewLines; $i++) {
203+
204+
$lastNonWhitespaceItem = $outStringResults.Count - 1
205+
while ([string]::IsNullOrWhiteSpace($outStringResults[$lastNonWhitespaceItem])) {
206+
$lastNonWhitespaceItem--
207+
}
208+
209+
for ($i = 0; $i -le $lastNonWhitespaceItem; $i++) {
205210
$ps.Streams.Information[$i].MessageData | Should -BeExactly $outStringResults[$i]
206211
$ps.Streams.Information[$i].Tags | Should -BeExactly "__PipelineObject__"
207212
}

0 commit comments

Comments
 (0)