MCPcopy Create free account
hub / github.com/basecamp/hey-cli / seenServer

Function seenServer

internal/cmd/seen_test.go:15–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func seenServer(t *testing.T) *httptest.Server {
16 t.Helper()
17 return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
18 switch {
19 case r.Method == "POST" && (r.URL.Path == "/postings/seen" || r.URL.Path == "/postings/seen.json"):
20 body, _ := io.ReadAll(r.Body)
21 var req map[string]any
22 _ = json.Unmarshal(body, &req)
23 if req["posting_ids"] == nil {
24 w.WriteHeader(400)
25 return
26 }
27 w.WriteHeader(201)
28 case r.Method == "POST" && (r.URL.Path == "/postings/unseen" || r.URL.Path == "/postings/unseen.json"):
29 body, _ := io.ReadAll(r.Body)
30 var req map[string]any
31 _ = json.Unmarshal(body, &req)
32 if req["posting_ids"] == nil {
33 w.WriteHeader(400)
34 return
35 }
36 w.WriteHeader(201)
37 case r.Method == "GET" && r.URL.Path == "/me.json":
38 w.Header().Set("Content-Type", "application/json")
39 w.WriteHeader(200)
40 _, _ = w.Write([]byte(`{"id": 1}`))
41 default:
42 w.WriteHeader(404)
43 }
44 }))
45}
46
47func runSeen(t *testing.T, server *httptest.Server, args ...string) (output.Response, error) {
48 t.Helper()

Callers 8

TestSeenSingleFunction · 0.85
TestSeenMultipleFunction · 0.85
TestSeenNoArgsFunction · 0.85
TestSeenInvalidIDFunction · 0.85
TestUnseenSingleFunction · 0.85
TestUnseenMultipleFunction · 0.85
TestUnseenNoArgsFunction · 0.85
TestUnseenInvalidIDFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected