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

Function TestRequestBatchContextError

modules/frontend/v1/request_batch_test.go:48–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func TestRequestBatchContextError(t *testing.T) {
49 rb := &requestBatch{}
50 ctx := context.Background()
51 const totalRequests = 3
52
53 req := httptest.NewRequest("GET", "http://example.com", nil)
54 prequest := pipeline.NewHTTPRequest(req)
55 prequest.SetContext(ctx)
56
57 for i := 0; i < totalRequests-1; i++ {
58 _ = rb.add(&request{request: prequest})
59 }
60
61 // add a cancel context
62 cancelCtx, cancel := context.WithCancel(ctx)
63 prequest = pipeline.NewHTTPRequest(req)
64 prequest.SetContext(cancelCtx)
65
66 _ = rb.add(&request{request: prequest})
67
68 // confirm ok
69 require.NoError(t, rb.contextError())
70
71 // cancel anc confirm error
72 cancel()
73 require.Error(t, rb.contextError())
74}
75
76func TestDoneChanCloses(_ *testing.T) {
77 rb := &requestBatch{}

Callers

nothing calls this directly

Calls 5

SetContextMethod · 0.95
addMethod · 0.95
contextErrorMethod · 0.95
NewHTTPRequestFunction · 0.92
ErrorMethod · 0.65

Tested by

no test coverage detected