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

Function TestAdjustLineWidth_TaskIDCorrectlyTruncated

cmd/display/tty_test.go:250–271  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

248}
249
250func TestAdjustLineWidth_TaskIDCorrectlyTruncated(t *testing.T) {
251 w := &ttyWriter{}
252 lines := []lineData{
253 {
254 taskID: "very-long-image-name-that-exceeds-minimum-length",
255 status: "Pulling",
256 details: "",
257 },
258 }
259
260 terminalWidth := 40
261 timerLen := 5
262 w.adjustLineWidth(lines, timerLen, terminalWidth)
263
264 lineWidth := 5 + len(lines[0].taskID) + 7 + timerLen
265
266 assert.Assert(t, lineWidth <= terminalWidth,
267 "line width %d should not exceed terminal width %d (taskID=%q)",
268 lineWidth, terminalWidth, lines[0].taskID)
269
270 assert.Assert(t, strings.HasSuffix(lines[0].taskID, "..."), "truncated taskID should end with ...")
271}
272
273// TestAdjustLineWidth_MultiByteTaskIDFits guards against drift between
274// applyPadding (rune-based) and maxBeforeStatusWidth (formerly byte-based):

Callers

nothing calls this directly

Calls 1

adjustLineWidthMethod · 0.95

Tested by

no test coverage detected