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

Function TestPrintWithDimensions_TaskWithProgress

cmd/display/tty_test.go:175–217  ·  cmd/display/tty_test.go::TestPrintWithDimensions_TaskWithProgress
(t *testing.T)

Source from the content-addressed store, hash-verified

173}
174
175func TestPrintWithDimensions_TaskWithProgress(t *testing.T) {
176 w, buf := newTestWriter()
177
178 // Create parent task
179 parent := &task{
180 ID: "Image nginx",
181 parents: make(map[string]struct{}),
182 startTime: time.Now(),
183 text: "Pulling",
184 status: api.Working,
185 spinner: NewSpinner(),
186 }
187 w.tasks["Image nginx"] = parent
188 w.ids = append(w.ids, "Image nginx")
189
190 // Create child tasks to trigger progress display
191 for i := range 3 {
192 child := &task{
193 ID: "layer" + string(rune('a'+i)),
194 parents: map[string]struct{}{"Image nginx": {}},
195 startTime: time.Now(),
196 text: "Downloading",
197 status: api.Working,
198 total: 1000,
199 current: 500,
200 percent: 50,
201 spinner: NewSpinner(),
202 }
203 w.tasks[child.ID] = child
204 w.ids = append(w.ids, child.ID)
205 }
206
207 terminalWidth := 80
208 w.printWithDimensions(terminalWidth, 24)
209
210 lines := extractLines(buf)
211 for i, line := range lines {
212 lineLen := lenAnsi(line)
213 assert.Assert(t, lineLen <= terminalWidth,
214 "line %d has length %d which exceeds terminal width %d: %q",
215 i, lineLen, terminalWidth, line)
216 }
217}
218
219func TestAdjustLineWidth_DetailsCorrectlyTruncated(t *testing.T) {
220 w := &ttyWriter{}

Callers

nothing calls this directly

Calls 5

newTestWriterFunction · 0.85
NewSpinnerFunction · 0.85
extractLinesFunction · 0.85
printWithDimensionsMethod · 0.80
lenAnsiFunction · 0.70

Tested by

no test coverage detected