TestTruncateProgressSize_PicksWidestLine verifies that dropping the size suffix targets the line currently driving maxBeforeStatusWidth (the only line whose shrink can reduce overflow), preserving size info on narrower lines that are not the bottleneck.
(t *testing.T)
| 310 | // line whose shrink can reduce overflow), preserving size info on narrower |
| 311 | // lines that are not the bottleneck. |
| 312 | func TestTruncateProgressSize_PicksWidestLine(t *testing.T) { |
| 313 | narrowSuffix := " 5MB / 10MB" |
| 314 | wideSuffix := " 50MB / 100MB" |
| 315 | lines := []lineData{ |
| 316 | { |
| 317 | taskID: "Image short", |
| 318 | progress: " [⣿⣿]" + narrowSuffix, |
| 319 | progressSizeBytes: len(narrowSuffix), |
| 320 | }, |
| 321 | { |
| 322 | taskID: "Image very-long-named-task", |
| 323 | progress: " [⣿⣿⣿⣿⣿⣿⣿⣿]" + wideSuffix, |
| 324 | progressSizeBytes: len(wideSuffix), |
| 325 | }, |
| 326 | } |
| 327 | |
| 328 | truncateProgressSize(lines) |
| 329 | |
| 330 | assert.Equal(t, 0, lines[1].progressSizeBytes, |
| 331 | "widest line should lose its size suffix first") |
| 332 | assert.Equal(t, len(narrowSuffix), lines[0].progressSizeBytes, |
| 333 | "narrower line should retain its size suffix") |
| 334 | } |
| 335 | |
| 336 | func TestAdjustLineWidth_NoTruncationNeeded(t *testing.T) { |
| 337 | w := &ttyWriter{} |
nothing calls this directly
no test coverage detected