MCPcopy
hub / github.com/kagent-dev/kagent / TestBuildHTTPClient_HeadersInjected

Function TestBuildHTTPClient_HeadersInjected

go/adk/pkg/models/tls_test.go:138–154  ·  view source on GitHub ↗

Should inject headers if specified

(t *testing.T)

Source from the content-addressed store, hash-verified

136
137// Should inject headers if specified
138func TestBuildHTTPClient_HeadersInjected(t *testing.T) {
139 var got string
140 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
141 got = r.Header.Get("X-Test")
142 w.WriteHeader(http.StatusOK)
143 }))
144 t.Cleanup(srv.Close)
145
146 client, err := BuildHTTPClient(TransportConfig{Headers: map[string]string{"X-Test": "hello"}})
147 if err != nil {
148 t.Fatalf("unexpected error: %v", err)
149 }
150 get(t, client, srv.URL)
151 if got != "hello" {
152 t.Errorf("expected X-Test 'hello', got %q", got)
153 }
154}

Callers

nothing calls this directly

Calls 4

BuildHTTPClientFunction · 0.85
getFunction · 0.85
GetMethod · 0.65
WriteHeaderMethod · 0.45

Tested by

no test coverage detected