Codebase list golang-github-vbauerster-mpb / 6f444e4
TestBarQueueAfterBar Vladimir Bauer 3 years ago
1 changed file(s) with 25 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
240240 t.Errorf("expected AvailableWidth %d got %d", 40, availableWidth)
241241 }
242242 }
243
244 func TestBarQueueAfterBar(t *testing.T) {
245 shutdown := make(chan interface{})
246 ctx, cancel := context.WithCancel(context.Background())
247 p := mpb.NewWithContext(ctx,
248 mpb.WithOutput(io.Discard),
249 mpb.WithShutdownNotifier(shutdown),
250 )
251 b := p.AddBar(100)
252 q := p.AddBar(100, mpb.BarQueueAfter(b))
253
254 b.IncrBy(100)
255 b.Wait()
256 cancel()
257
258 bars := (<-shutdown).([]*mpb.Bar)
259 if l := len(bars); l != 1 {
260 t.Errorf("Expected len of bars: %d, got: %d", 1, l)
261 }
262
263 p.Wait()
264 if bars[0] != q {
265 t.Errorf("Expected bars[0]: %p, got: %p", q, bars[0])
266 }
267 }