MCPcopy
hub / github.com/usefathom/fathom / TestRespond

Function TestRespond

pkg/api/http_test.go:10–30  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestRespond(t *testing.T) {
11 w := httptest.NewRecorder()
12 respond(w, http.StatusOK, 15)
13
14 if w.Code != 200 {
15 t.Errorf("Invalid response code")
16 }
17
18 // assert json header
19 if w.Header().Get("Content-Type") != "application/json" {
20 t.Errorf("Invalid response header for Content-Type")
21 }
22
23 // assert json response
24 var d int
25 err := json.NewDecoder(w.Body).Decode(&d)
26 if err != nil {
27 t.Errorf("Invalid response body: %s", err)
28 }
29
30}

Callers

nothing calls this directly

Calls 1

respondFunction · 0.85

Tested by

no test coverage detected