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

Function TestRequestBatchBasics

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

Source from the content-addressed store, hash-verified

16)
17
18func TestRequestBatchBasics(t *testing.T) {
19 rb := &requestBatch{}
20
21 const totalRequests = 3
22
23 for i := byte(0); i < totalRequests; i++ {
24 req := httptest.NewRequest("GET", "http://example.com", bytes.NewReader([]byte{i}))
25 _ = rb.add(&request{
26 request: pipeline.NewHTTPRequest(req),
27 })
28 }
29
30 // confirm len
31 require.Equal(t, totalRequests, rb.len())
32
33 // confirm grpc requests are ordered
34 grpcRequests := rb.httpGrpcRequests()
35 require.Equal(t, totalRequests, len(grpcRequests))
36 for i := byte(0); i < byte(len(grpcRequests)); i++ {
37 require.Equal(t, []byte{i}, grpcRequests[i].Body)
38 }
39
40 // clear and confirm len
41 rb.clear()
42 require.Equal(t, 0, rb.len())
43
44 grpcRequests = rb.httpGrpcRequests()
45 require.Equal(t, 0, len(grpcRequests))
46}
47
48func TestRequestBatchContextError(t *testing.T) {
49 rb := &requestBatch{}

Callers

nothing calls this directly

Calls 6

addMethod · 0.95
lenMethod · 0.95
httpGrpcRequestsMethod · 0.95
clearMethod · 0.95
NewHTTPRequestFunction · 0.92
EqualMethod · 0.45

Tested by

no test coverage detected