make sure every test has WithWidth
Vladimir Bauer
6 years ago
| 14 | 14 | ) |
| 15 | 15 | |
| 16 | 16 | func TestBarCompleted(t *testing.T) { |
| 17 | p := New(WithOutput(ioutil.Discard)) | |
| 17 | p := New(WithWidth(80), WithOutput(ioutil.Discard)) | |
| 18 | 18 | total := 80 |
| 19 | 19 | bar := p.AddBar(int64(total)) |
| 20 | 20 | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | func TestBarID(t *testing.T) { |
| 35 | p := New(WithOutput(ioutil.Discard)) | |
| 35 | p := New(WithWidth(80), WithOutput(ioutil.Discard)) | |
| 36 | 36 | total := 100 |
| 37 | 37 | wantID := 11 |
| 38 | 38 | bar := p.AddBar(int64(total), BarID(wantID)) |
| 56 | 56 | func TestBarSetRefill(t *testing.T) { |
| 57 | 57 | var buf bytes.Buffer |
| 58 | 58 | |
| 59 | width := 100 | |
| 60 | p := New(WithOutput(&buf), WithWidth(width)) | |
| 59 | p := New(WithOutput(&buf), WithWidth(100)) | |
| 61 | 60 | |
| 62 | 61 | total := 100 |
| 63 | 62 | till := 30 |
| 90 | 89 | func TestBarHas100PercentWithOnCompleteDecorator(t *testing.T) { |
| 91 | 90 | var buf bytes.Buffer |
| 92 | 91 | |
| 93 | p := New(WithOutput(&buf), WithWidth(80)) | |
| 92 | p := New(WithWidth(80), WithOutput(&buf)) | |
| 94 | 93 | |
| 95 | 94 | total := 50 |
| 96 | 95 | |
| 118 | 117 | func TestBarHas100PercentWithBarRemoveOnComplete(t *testing.T) { |
| 119 | 118 | var buf bytes.Buffer |
| 120 | 119 | |
| 121 | p := New(WithOutput(&buf), WithWidth(80)) | |
| 120 | p := New(WithWidth(80), WithOutput(&buf)) | |
| 122 | 121 | |
| 123 | 122 | total := 50 |
| 124 | 123 | |
| 144 | 143 | var buf bytes.Buffer |
| 145 | 144 | customFormat := "╢▌▌░╟" |
| 146 | 145 | total := 80 |
| 147 | p := New(WithOutput(&buf), WithWidth(total)) | |
| 146 | p := New(WithWidth(total), WithOutput(&buf)) | |
| 148 | 147 | bar := p.AddBar(int64(total), BarStyle(customFormat), TrimSpace()) |
| 149 | 148 | |
| 150 | 149 | for i := 0; i < total; i++ { |
| 170 | 169 | func TestBarPanicBeforeComplete(t *testing.T) { |
| 171 | 170 | var buf bytes.Buffer |
| 172 | 171 | p := New( |
| 172 | WithWidth(80), | |
| 173 | 173 | WithDebugOutput(&buf), |
| 174 | 174 | WithOutput(ioutil.Discard), |
| 175 | WithWidth(80), | |
| 176 | 175 | ) |
| 177 | 176 | |
| 178 | 177 | total := 100 |
| 210 | 209 | func TestBarPanicAfterComplete(t *testing.T) { |
| 211 | 210 | var buf bytes.Buffer |
| 212 | 211 | p := New( |
| 212 | WithWidth(80), | |
| 213 | 213 | WithDebugOutput(&buf), |
| 214 | 214 | WithOutput(ioutil.Discard), |
| 215 | WithWidth(80), | |
| 216 | 215 | ) |
| 217 | 216 | |
| 218 | 217 | total := 100 |