Codebase list golang-github-vbauerster-mpb / f01cfac
Update proxyreader_test Vladimir Bauer 9 years ago
1 changed file(s) with 6 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
2121
2222 func TestProxyReader(t *testing.T) {
2323 var buf bytes.Buffer
24 p := mpb.New().SetOut(&buf)
24 p := mpb.New(mpb.Output(&buf))
2525
2626 reader := strings.NewReader(content)
2727
28 total := int64(len(content))
29 bar := p.AddBar(total).TrimLeftSpace().TrimRightSpace()
28 total := len(content)
29 bar := p.AddBar(100, mpb.BarTrim())
3030 preader := bar.ProxyReader(reader)
3131
3232 written, err := io.Copy(ioutil.Discard, preader)
3636
3737 p.Stop()
3838
39 if written != total {
39 if written != int64(total) {
4040 t.Errorf("Expected written: %d, got: %d\n", total, written)
4141 }
4242
4949
5050 func TestProxyReaderCloser(t *testing.T) {
5151 var buf bytes.Buffer
52 p := mpb.New().SetOut(&buf)
52 p := mpb.New(mpb.Output(&buf))
5353
5454 ts := setupTestHttpServer(content)
5555 defer ts.Close()
6161 }
6262
6363 total := resp.ContentLength
64 bar := p.AddBar(total).TrimLeftSpace().TrimRightSpace()
64 bar := p.AddBar(total, mpb.BarTrim())
6565 reader := bar.ProxyReader(resp.Body)
6666
6767 // calling reader.Close() will call resp.Body.Close() implicitly