Skip to content

Commit b579592

Browse files
svelderrainruizGitHub Copilot
andauthored
Follow-up #971 Trim Docker fast-loop diagnostic strings (#974)
#971 Trim Docker fast-loop diagnostic strings Co-authored-by: GitHub Copilot <copilot@users.noreply.github.com>
1 parent 9ff021f commit b579592

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

tests/Show-DockerFastLoopDiagnostics.Tests.ps1

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,44 @@ Describe 'Show-DockerFastLoopDiagnostics.ps1' -Tag 'Unit' {
115115
$outputText | Should -Match 'capture=history-scenarios\\sequential\\block-diagram\\ni-windows-container-capture.json'
116116
}
117117

118+
It 'trims space-padded history metadata before rendering differentiated diagnostics' {
119+
$resultsRoot = Join-Path $TestDrive 'trimmed-metadata'
120+
New-Item -ItemType Directory -Path $resultsRoot -Force | Out-Null
121+
$historyRoot = Join-Path $resultsRoot 'history-scenarios'
122+
New-Item -ItemType Directory -Path (Join-Path $historyRoot 'attribute\container-export') -Force | Out-Null
123+
$readinessPath = Join-Path $resultsRoot 'docker-runtime-fastloop-readiness.json'
124+
([ordered]@{
125+
schema = 'vi-history/docker-fast-loop-readiness@v1'
126+
historyScenarioSet = ' smoke '
127+
source = [ordered]@{
128+
resultsRoot = $resultsRoot
129+
}
130+
steps = @(
131+
[ordered]@{
132+
name = ' windows-history-attribute '
133+
historyLane = ' windows '
134+
historyMode = ' attribute '
135+
historySequence = ' direct '
136+
isDiff = $true
137+
diffImageCount = 3
138+
durationMs = 1500
139+
diffEvidenceSource = ' html '
140+
containerExportStatus = ' success '
141+
extractedReportPath = " $(Join-Path $historyRoot 'attribute\container-export\windows-compare-report.html') "
142+
capturePath = " $(Join-Path $historyRoot 'attribute\ni-windows-container-capture.json') "
143+
}
144+
)
145+
} | ConvertTo-Json -Depth 8) | Set-Content -LiteralPath $readinessPath -Encoding utf8
146+
147+
$output = & pwsh -NoLogo -NoProfile -File $script:ShowScript -ReadinessPath $readinessPath *>&1
148+
$LASTEXITCODE | Should -Be 0 -Because ($output -join "`n")
149+
150+
$outputText = $output -join "`n"
151+
$outputText | Should -Match '\[windows-docker-fast-loop\]\[diagnostics\] scenarioSet=smoke differentiatedSteps=1 evidenceSteps=0 reports=0'
152+
$outputText | Should -Match 'lane=windows sequence=direct mode=attribute images=3'
153+
$outputText | Should -Match 'report=history-scenarios\\attribute\\container-export\\windows-compare-report.html'
154+
}
155+
118156
It 'prints an explicit no-diagnostics message when no history diff steps exist' {
119157
$resultsRoot = Join-Path $TestDrive 'no-diff'
120158
New-Item -ItemType Directory -Path $resultsRoot -Force | Out-Null

tools/DockerFastLoopDiagnostics.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function Convert-ToTrimmedString {
3131
if ($null -eq $Value) {
3232
return ''
3333
}
34-
return [string]$Value
34+
return ([string]$Value).Trim()
3535
}
3636

3737
function Convert-ToBoolean {

0 commit comments

Comments
 (0)