MCPcopy
hub / github.com/docker/compose / TestTruncateProgressSize_PicksWidestLine

Function TestTruncateProgressSize_PicksWidestLine

cmd/display/tty_test.go:312–334  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

310// line whose shrink can reduce overflow), preserving size info on narrower
311// lines that are not the bottleneck.
312func 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
336func TestAdjustLineWidth_NoTruncationNeeded(t *testing.T) {
337 w := &ttyWriter{}

Callers

nothing calls this directly

Calls 1

truncateProgressSizeFunction · 0.85

Tested by

no test coverage detected