fix tests
Vladimir Bauer
6 years ago
| 90 | 90 |
func TestBarHas100PercentWithOnCompleteDecorator(t *testing.T) {
|
| 91 | 91 |
var buf bytes.Buffer
|
| 92 | 92 |
|
| 93 | |
p := New(WithOutput(&buf))
|
|
93 |
p := New(WithOutput(&buf), WithWidth(80))
|
| 94 | 94 |
|
| 95 | 95 |
total := 50
|
| 96 | 96 |
|
|
| 118 | 118 |
func TestBarHas100PercentWithBarRemoveOnComplete(t *testing.T) {
|
| 119 | 119 |
var buf bytes.Buffer
|
| 120 | 120 |
|
| 121 | |
p := New(WithOutput(&buf))
|
|
121 |
p := New(WithOutput(&buf), WithWidth(80))
|
| 122 | 122 |
|
| 123 | 123 |
total := 50
|
| 124 | 124 |
|
| 21 | 21 |
total: 60,
|
| 22 | 22 |
current: 20,
|
| 23 | 23 |
barWidth: 80,
|
| 24 | |
want: " ",
|
|
24 |
want: "… ",
|
| 25 | 25 |
},
|
| 26 | 26 |
{
|
| 27 | 27 |
name: "t,c,bw{60,20,80}trim",
|
|
| 38 | 38 |
total: 60,
|
| 39 | 39 |
current: 20,
|
| 40 | 40 |
barWidth: 80,
|
| 41 | |
want: " ",
|
|
41 |
want: "… ",
|
| 42 | 42 |
},
|
| 43 | 43 |
{
|
| 44 | 44 |
name: "t,c,bw{60,20,80}trim",
|
|
| 318 | 318 |
}
|
| 319 | 319 |
|
| 320 | 320 |
var tmpBuf bytes.Buffer
|
| 321 | |
for termWidth, cases := range testSuite {
|
|
321 |
for tw, cases := range testSuite {
|
| 322 | 322 |
for _, tc := range cases {
|
| 323 | 323 |
s := newTestState(tc.reverse)
|
| 324 | 324 |
s.reqWidth = tc.barWidth
|
|
| 331 | 331 |
}
|
| 332 | 332 |
}
|
| 333 | 333 |
tmpBuf.Reset()
|
| 334 | |
tmpBuf.ReadFrom(s.draw(newStatistics(termWidth, s)))
|
|
334 |
tmpBuf.ReadFrom(s.draw(newStatistics(tw, s)))
|
| 335 | 335 |
by := tmpBuf.Bytes()
|
| 336 | 336 |
by = by[:len(by)-1]
|
| 337 | 337 |
|
| 338 | 338 |
got := string(by)
|
| 339 | 339 |
if got != tc.want {
|
| 340 | |
t.Errorf("termWidth:%d %q want: %q %d, got: %q %d\n", termWidth, tc.name, tc.want, len(tc.want), got, len(got))
|
|
340 |
t.Errorf("termWidth:%d %q want: %q %d, got: %q %d\n", tw, tc.name, tc.want, len(tc.want), got, len(got))
|
| 341 | 341 |
}
|
| 342 | 342 |
}
|
| 343 | 343 |
}
|