MCPcopy Create free account
hub / github.com/chainreactors/spray / TestPutToOutput_OutwgBalance

Function TestPutToOutput_OutwgBalance

core/pool/pool_test.go:520–544  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

518}
519
520func TestPutToOutput_OutwgBalance(t *testing.T) {
521 ctx, cancel := context.WithCancel(context.Background())
522 pool := newTestBasePool(ctx, cancel)
523
524 // fill OutputCh so next send will block
525 for i := 0; i < cap(pool.OutputCh); i++ {
526 pool.OutputCh <- newTestBaseline()
527 pool.Outwg.Add(1) // manual balance for the fills
528 }
529
530 mustFinish(t, 2*time.Second, "putToOutput on full ch not unblocked by cancel", func() {
531 go func() {
532 time.Sleep(50 * time.Millisecond)
533 cancel()
534 }()
535 pool.putToOutput(newTestBaseline())
536 })
537
538 // drain and done for fills
539 for i := 0; i < cap(pool.OutputCh); i++ {
540 <-pool.OutputCh
541 pool.Outwg.Done()
542 }
543 pool.Outwg.Wait()
544}
545
546// ---------------------------------------------------------------------------
547// putToFuzzy

Callers

nothing calls this directly

Calls 5

newTestBasePoolFunction · 0.85
newTestBaselineFunction · 0.85
mustFinishFunction · 0.85
putToOutputMethod · 0.80
DoneMethod · 0.45

Tested by

no test coverage detected