add TestBarAborted
Vladimir Bauer
4 years ago
| 28 | 28 | |
| 29 | 29 | if !bar.Completed() { |
| 30 | 30 | t.Error("bar isn't completed after increment") |
| 31 | } | |
| 32 | ||
| 33 | p.Wait() | |
| 34 | } | |
| 35 | ||
| 36 | func TestBarAborted(t *testing.T) { | |
| 37 | p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(ioutil.Discard)) | |
| 38 | total := 80 | |
| 39 | bar := p.AddBar(int64(total)) | |
| 40 | ||
| 41 | if bar.Aborted() { | |
| 42 | t.Fail() | |
| 43 | } | |
| 44 | ||
| 45 | bar.Abort(false) | |
| 46 | ||
| 47 | if !bar.Aborted() { | |
| 48 | t.Error("bar isn't aborted after abort call") | |
| 31 | 49 | } |
| 32 | 50 | |
| 33 | 51 | p.Wait() |