Codebase list golang-github-vbauerster-mpb / 77f9d16
dot import Vladimir Bauer 8 years ago
1 changed file(s) with 10 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
88 "testing"
99 "time"
1010
11 "github.com/vbauerster/mpb"
11 . "github.com/vbauerster/mpb"
1212 "github.com/vbauerster/mpb/decor"
1313 )
1414
1515 func TestBarCompleted(t *testing.T) {
16 p := mpb.New(mpb.WithOutput(ioutil.Discard))
16 p := New(WithOutput(ioutil.Discard))
1717 total := 80
1818 bar := p.AddBar(int64(total))
1919
3131 }
3232
3333 func TestBarID(t *testing.T) {
34 p := mpb.New(mpb.WithOutput(ioutil.Discard))
34 p := New(WithOutput(ioutil.Discard))
3535
3636 numBars := 3
37 bars := make([]*mpb.Bar, numBars)
37 bars := make([]*Bar, numBars)
3838 for i := 0; i < numBars; i++ {
39 bars[i] = p.AddBar(80, mpb.BarID(i))
40 go func(bar *mpb.Bar) {
39 bars[i] = p.AddBar(80, BarID(i))
40 go func(bar *Bar) {
4141 for i := 0; i < 80; i++ {
4242 time.Sleep(10 * time.Millisecond)
4343 bar.Increment()
5858 var buf bytes.Buffer
5959
6060 width := 100
61 p := mpb.New(
62 mpb.WithOutput(&buf),
63 mpb.WithWidth(width),
64 )
61 p := New(WithOutput(&buf), WithWidth(width))
6562
6663 total := 100
6764 till := 30
6865 refillChar := '+'
6966
70 bar := p.AddBar(100, mpb.BarTrim())
67 bar := p.AddBar(100, BarTrim())
7168
7269 bar.ResumeFill(refillChar, int64(till))
7370
9087 func TestBarPanics(t *testing.T) {
9188 var wg sync.WaitGroup
9289 var buf bytes.Buffer
93 p := mpb.New(mpb.WithOutput(&buf), mpb.WithWaitGroup(&wg))
90 p := New(WithOutput(&buf), WithWaitGroup(&wg))
9491
9592 wantPanic := "Upps!!!"
9693 numBars := 3
9895
9996 for i := 0; i < numBars; i++ {
10097 name := fmt.Sprintf("b#%02d:", i)
101 bar := p.AddBar(100, mpb.BarID(i), mpb.PrependDecorators(
98 bar := p.AddBar(100, BarID(i), PrependDecorators(
10299 func(s *decor.Statistics, _ chan<- int, _ <-chan int) string {
103100 if s.ID == 2 && s.Current >= 42 {
104101 panic(wantPanic)