MCPcopy
hub / github.com/grafana/tempo / TestDoneChanCloses

Function TestDoneChanCloses

modules/frontend/v1/request_batch_test.go:76–103  ·  view source on GitHub ↗
(_ *testing.T)

Source from the content-addressed store, hash-verified

74}
75
76func TestDoneChanCloses(_ *testing.T) {
77 rb := &requestBatch{}
78
79 const totalRequests = 3
80
81 ctx := context.Background()
82 cancelCtx, cancel := context.WithCancel(ctx)
83
84 req := httptest.NewRequest("GET", "http://example.com", nil)
85 prequest := pipeline.NewHTTPRequest(req)
86 prequest.SetContext(cancelCtx)
87
88 for i := 0; i < totalRequests-1; i++ {
89 _ = rb.add(&request{request: prequest})
90 }
91
92 wg := &sync.WaitGroup{}
93 wg.Add(1)
94 go func() {
95 done := rb.doneChan(make(<-chan struct{}))
96 <-done
97 wg.Done()
98 }()
99
100 cancel()
101 wg.Wait()
102 // this test won't return unless doneChan closes
103}
104
105func TestDoneChanClosesOnStop(_ *testing.T) {
106 rb := &requestBatch{}

Callers

nothing calls this directly

Calls 7

SetContextMethod · 0.95
addMethod · 0.95
doneChanMethod · 0.95
NewHTTPRequestFunction · 0.92
AddMethod · 0.65
DoneMethod · 0.65
WaitMethod · 0.65

Tested by

no test coverage detected