MCPcopy Create free account
hub / github.com/dave/blast / TestHeaders

Function TestHeaders

httpworker/httpworker_test.go:71–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

69}
70
71func TestHeaders(t *testing.T) {
72 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
73 if r.Method != "GET" {
74 t.Errorf("Unexpected method: %s", r.Method)
75 }
76 if r.Header.Get("a") != "b" || r.Header.Get("c") != "d" {
77 t.Errorf("Unexpected: a=%s, c=%s", r.Header.Get("a"), r.Header.Get("c"))
78 }
79 }))
80 defer ts.Close()
81
82 payload := map[string]interface{}{
83 "method": "GET",
84 "url": ts.URL,
85 "headers": map[string]string{
86 "a": "b",
87 "c": "d",
88 },
89 }
90 response, err := New().Send(context.Background(), payload)
91 expected := map[string]interface{}{
92 "status": 200,
93 }
94 if err != nil {
95 log.Fatal(err)
96 }
97 if !reflect.DeepEqual(response, expected) {
98 t.Fatalf("Unexpected: %#v", response)
99 }
100}
101
102func TestError(t *testing.T) {
103 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 3

NewFunction · 0.70
SendMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected