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

Function TestAdjustLineWidth_DetailsCorrectlyTruncated

cmd/display/tty_test.go:219–248  ·  cmd/display/tty_test.go::TestAdjustLineWidth_DetailsCorrectlyTruncated
(t *testing.T)

Source from the content-addressed store, hash-verified

217}
218
219func TestAdjustLineWidth_DetailsCorrectlyTruncated(t *testing.T) {
220 w := &ttyWriter{}
221 lines := []lineData{
222 {
223 taskID: "Image foo",
224 status: "Pulling",
225 details: "downloading layer sha256:abc123def456789xyz",
226 },
227 }
228
229 terminalWidth := 50
230 timerLen := 5
231 w.adjustLineWidth(lines, timerLen, terminalWidth)
232
233 // Verify the line fits
234 detailsLen := len(lines[0].details)
235 if detailsLen > 0 {
236 detailsLen++ // space before details
237 }
238 // widthWithoutDetails = 5 + prefix(0) + taskID(9) + progress(0) + status(7) + timer(5) = 26
239 lineWidth := 5 + len(lines[0].taskID) + len(lines[0].status) + detailsLen + timerLen
240
241 assert.Assert(t, lineWidth <= terminalWidth,
242 "line width %d should not exceed terminal width %d (taskID=%q, details=%q)",
243 lineWidth, terminalWidth, lines[0].taskID, lines[0].details)
244
245 // Verify details were truncated (not removed entirely)
246 assert.Assert(t, lines[0].details != "", "details should be truncated, not removed")
247 assert.Assert(t, strings.HasSuffix(lines[0].details, "..."), "truncated details should end with ...")
248}
249
250func TestAdjustLineWidth_TaskIDCorrectlyTruncated(t *testing.T) {
251 w := &ttyWriter{}

Callers

nothing calls this directly

Calls 1

adjustLineWidthMethod · 0.95

Tested by

no test coverage detected