mirror of https://github.com/docker/compose.git
Merge pull request #1230 from gtardif/fix_progress_time_display
Avoid negative elapsed the display when only one event is sent.
This commit is contained in:
commit
af62c52716
|
@ -154,7 +154,10 @@ func (w *ttyWriter) print() {
|
|||
func lineText(event Event, pad string, terminalWidth, statusPadding int, color bool) string {
|
||||
endTime := time.Now()
|
||||
if event.Status != Working {
|
||||
endTime = event.endTime
|
||||
endTime = event.startTime
|
||||
if (event.endTime != time.Time{}) {
|
||||
endTime = event.endTime
|
||||
}
|
||||
}
|
||||
|
||||
elapsed := endTime.Sub(event.startTime).Seconds()
|
||||
|
|
|
@ -56,6 +56,25 @@ func TestLineText(t *testing.T) {
|
|||
assert.Equal(t, out, "\x1b[31m . id Text Status 0.0s\n\x1b[0m")
|
||||
}
|
||||
|
||||
func TestLineTextSingleEvent(t *testing.T) {
|
||||
now := time.Now()
|
||||
ev := Event{
|
||||
ID: "id",
|
||||
Text: "Text",
|
||||
Status: Done,
|
||||
StatusText: "Status",
|
||||
startTime: now,
|
||||
spinner: &spinner{
|
||||
chars: []string{"."},
|
||||
},
|
||||
}
|
||||
|
||||
lineWidth := len(fmt.Sprintf("%s %s", ev.ID, ev.Text))
|
||||
|
||||
out := lineText(ev, "", 50, lineWidth, true)
|
||||
assert.Equal(t, out, "\x1b[34m . id Text Status 0.0s\n\x1b[0m")
|
||||
}
|
||||
|
||||
func TestErrorEvent(t *testing.T) {
|
||||
w := &ttyWriter{
|
||||
events: map[string]Event{},
|
||||
|
|
Loading…
Reference in New Issue