Codebase list golang-github-vbauerster-mpb / 3c29c8c
fix test timed out Vladimir Bauer 4 years ago
1 changed file(s) with 8 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
254254 }
255255
256256 func TestDecorStatisticsAvailableWidth(t *testing.T) {
257 total := 100
258 down := make(chan struct{})
259 checkDone := make(chan struct{})
257260 td1 := func(s decor.Statistics) string {
258261 if s.AvailableWidth != 80 {
259262 t.Errorf("expected AvailableWidth %d got %d\n", 80, s.AvailableWidth)
260263 }
261264 return fmt.Sprintf("\x1b[31;1;4m%s\x1b[0m", strings.Repeat("0", 20))
262265 }
263 checkDone := make(chan struct{})
264266 td2 := func(s decor.Statistics) string {
265267 defer func() {
266 checkDone <- struct{}{}
268 select {
269 case checkDone <- struct{}{}:
270 default:
271 }
267272 }()
268273 if s.AvailableWidth != 40 {
269274 t.Errorf("expected AvailableWidth %d got %d\n", 40, s.AvailableWidth)
270275 }
271276 return ""
272277 }
273 total := 100
274 down := make(chan struct{})
275278 p := mpb.New(
276279 mpb.WithWidth(100),
277280 mpb.WithShutdownNotifier(down),
292295 for {
293296 select {
294297 case <-checkDone:
295 bar.Abort(false)
298 bar.Abort(true)
296299 case <-down:
297300 return
298301 }