(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func 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 | |
| 47 | func runSeen(t *testing.T, server *httptest.Server, args ...string) (output.Response, error) { |
| 48 | t.Helper() |
no outgoing calls
no test coverage detected