MCPcopy Create free account
hub / github.com/DoNewsCode/core / TestClient_context

Function TestClient_context

clihttp/client_test.go:94–107  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

92}
93
94func TestClient_context(t *testing.T) {
95 ctx := context.Background()
96 tracer := mocktracer.New()
97 span1, ctx := opentracing.StartSpanFromContextWithTracer(ctx, tracer, "span1")
98 span1.SetBaggageItem("foo", "bar")
99 span1.Finish()
100 req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "https://example.com/", nil)
101
102 client := NewClient(tracer)
103 resp, _ := client.Do(req)
104 defer resp.Body.Close()
105 assert.Len(t, tracer.FinishedSpans(), 2)
106 assert.Equal(t, "bar", tracer.FinishedSpans()[1].BaggageItem("foo"))
107}

Callers

nothing calls this directly

Calls 4

DoMethod · 0.95
NewClientFunction · 0.85
CloseMethod · 0.80
LenMethod · 0.45

Tested by

no test coverage detected