Codebase list golang-github-vbauerster-mpb / cbd9e20
drop io/ioutil Vladimir Bauer 3 years ago
7 changed file(s) with 21 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
33 "bytes"
44 "context"
55 "fmt"
6 "io/ioutil"
6 "io"
77 "strings"
88 "sync/atomic"
99 "testing"
1515 )
1616
1717 func TestBarCompleted(t *testing.T) {
18 p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(ioutil.Discard))
18 p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(io.Discard))
1919 total := 80
2020 bar := p.AddBar(int64(total))
2121
3333 }
3434
3535 func TestBarAborted(t *testing.T) {
36 p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(ioutil.Discard))
36 p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(io.Discard))
3737 total := 80
3838 bar := p.AddBar(int64(total))
3939
5151 }
5252
5353 func TestBarEnableTriggerCompleteAndIncrementBefore(t *testing.T) {
54 p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(ioutil.Discard))
54 p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(io.Discard))
5555 bar := p.AddBar(0) // never complete bar
5656
5757 for _, f := range []func(){
7676 }
7777
7878 func TestBarEnableTriggerCompleteAndIncrementAfter(t *testing.T) {
79 p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(ioutil.Discard))
79 p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(io.Discard))
8080 bar := p.AddBar(0) // never complete bar
8181
8282 for _, f := range []func(){
101101 }
102102
103103 func TestBarID(t *testing.T) {
104 p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(ioutil.Discard))
104 p := mpb.New(mpb.WithWidth(80), mpb.WithOutput(io.Discard))
105105 total := 100
106106 wantID := 11
107107 bar := p.AddBar(int64(total), mpb.BarID(wantID))
203203 p := mpb.New(
204204 mpb.WithWidth(80),
205205 mpb.WithDebugOutput(&buf),
206 mpb.WithOutput(ioutil.Discard),
206 mpb.WithOutput(io.Discard),
207207 )
208208
209209 total := 100
240240 p := mpb.New(
241241 mpb.WithWidth(80),
242242 mpb.WithDebugOutput(&buf),
243 mpb.WithOutput(ioutil.Discard),
243 mpb.WithOutput(io.Discard),
244244 )
245245
246246 total := 100
292292 refresh := make(chan interface{})
293293 p := mpb.NewWithContext(ctx, mpb.WithWidth(100),
294294 mpb.WithManualRefresh(refresh),
295 mpb.WithOutput(ioutil.Discard),
295 mpb.WithOutput(io.Discard),
296296 )
297297 _ = p.AddBar(0,
298298 mpb.BarFillerTrim(),
11
22 import (
33 "io"
4 "io/ioutil"
54 "sync"
65 "time"
76 )
7372 func WithOutput(w io.Writer) ContainerOption {
7473 return func(s *pState) {
7574 if w == nil {
76 s.output = ioutil.Discard
75 s.output = io.Discard
7776 s.outputDiscarded = true
7877 return
7978 }
22 import (
33 "bytes"
44 "fmt"
5 "io/ioutil"
5 "io"
66 "strconv"
77 "testing"
88 )
99
1010 var (
11 out = ioutil.Discard
11 out = io.Discard
1212 lines = 99
1313 )
1414
22 import (
33 crand "crypto/rand"
44 "io"
5 "io/ioutil"
65 "math/rand"
76 "time"
87
7776 defer proxyReader.Close()
7877
7978 // and copy from reader, ignoring errors
80 _, _ = io.Copy(ioutil.Discard, proxyReader)
79 _, _ = io.Copy(io.Discard, proxyReader)
8180
8281 p.Wait()
8382 }
11
22 import (
33 "context"
4 "io/ioutil"
4 "io"
55 "math/rand"
66 "testing"
77 "time"
2020
2121 func TestBarCount(t *testing.T) {
2222 shutdown := make(chan struct{})
23 p := mpb.New(mpb.WithShutdownNotifier(shutdown), mpb.WithOutput(ioutil.Discard))
23 p := mpb.New(mpb.WithShutdownNotifier(shutdown), mpb.WithOutput(io.Discard))
2424
2525 b := p.AddBar(0, mpb.BarRemoveOnComplete())
2626
4747
4848 func TestBarAbort(t *testing.T) {
4949 shutdown := make(chan struct{})
50 p := mpb.New(mpb.WithShutdownNotifier(shutdown), mpb.WithOutput(ioutil.Discard))
50 p := mpb.New(mpb.WithShutdownNotifier(shutdown), mpb.WithOutput(io.Discard))
5151 n := 2
5252 bars := make([]*mpb.Bar, n)
5353 for i := 0; i < n; i++ {
9696 func TestWithContext(t *testing.T) {
9797 shutdown := make(chan struct{})
9898 ctx, cancel := context.WithCancel(context.Background())
99 p := mpb.NewWithContext(ctx, mpb.WithShutdownNotifier(shutdown), mpb.WithOutput(ioutil.Discard))
99 p := mpb.NewWithContext(ctx, mpb.WithShutdownNotifier(shutdown), mpb.WithOutput(io.Discard))
100100
101101 done := make(chan struct{})
102102 bar := p.AddBar(0) // never complete bar
138138
139139 total := 100
140140 numBars := 6
141 p := mpb.New(mpb.WithOutput(ioutil.Discard))
141 p := mpb.New(mpb.WithOutput(io.Discard))
142142 for i := 0; i < numBars; i++ {
143143 bar := p.AddBar(int64(total),
144144 mpb.BarOptional(mpb.BarRemoveOnComplete(), i == 0),
11
22 import (
33 "io"
4 "io/ioutil"
54 "time"
65 )
76
7574 if rc, ok := r.(io.ReadCloser); ok {
7675 return rc
7776 }
78 return ioutil.NopCloser(r)
77 return io.NopCloser(r)
7978 }
22 import (
33 "bytes"
44 "io"
5 "io/ioutil"
65 "strings"
76 "testing"
87
3837 }
3938
4039 func TestProxyReader(t *testing.T) {
41 p := mpb.New(mpb.WithOutput(ioutil.Discard))
40 p := mpb.New(mpb.WithOutput(io.Discard))
4241
4342 tReader := &testReader{strings.NewReader(content), false}
4443
6261 }
6362
6463 func TestProxyWriterTo(t *testing.T) {
65 p := mpb.New(mpb.WithOutput(ioutil.Discard))
64 p := mpb.New(mpb.WithOutput(io.Discard))
6665
6766 var reader io.Reader = strings.NewReader(content)
6867 tWriterTo := testWriterTo{&testReader{reader, false}, reader.(io.WriterTo)}