Debian Codegraph @

internal/progress/progress_test.go

raw symbols SCIP
1 package progress
2
3 import (
4 "bytes"
5 "testing"
6 "time"
7 )
8
9 func TestProgress(t *testing.T) {
10 now := time.Now()
11 var buf bytes.Buffer
12 p := NewPrinter(&buf, func() time.Time {
13 return now
14 })
15 p.Reset(1234)
16 p.Show(0, false)
17 if got, want := buf.String(), " 0 0% 0.00kB/s 0:00:00"; got != want {
18 t.Errorf("progress.Show(0) = %q, want %q", got, want)
19 }
20 now = now.Add(1 * time.Second)
21 buf.Reset()
22 p.Show(617, false)
23 if got, want := buf.String(), "\r 617 50% 0.60kB/s 0:00:01"; got != want {
24 t.Errorf("progress.Show(617) = %q, want %q", got, want)
25 }
26 }