(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func todoServer(t *testing.T) *httptest.Server { |
| 17 | t.Helper() |
| 18 | return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 19 | switch { |
| 20 | case r.Method == "POST" && r.URL.Path == "/calendar/todos.json": |
| 21 | body, _ := io.ReadAll(r.Body) |
| 22 | var req map[string]any |
| 23 | _ = json.Unmarshal(body, &req) |
| 24 | todo, _ := req["calendar_todo"].(map[string]any) |
| 25 | title := "" |
| 26 | if todo != nil { |
| 27 | title, _ = todo["title"].(string) |
| 28 | } |
| 29 | resp := map[string]any{ |
| 30 | "id": 1, |
| 31 | "title": title, |
| 32 | } |
| 33 | w.Header().Set("Content-Type", "application/json") |
| 34 | json.NewEncoder(w).Encode(resp) |
| 35 | default: |
| 36 | w.WriteHeader(200) |
| 37 | } |
| 38 | })) |
| 39 | } |
| 40 | |
| 41 | func runTodoAdd(t *testing.T, server *httptest.Server, args ...string) (output.Response, error) { |
| 42 | t.Helper() |
no outgoing calls
no test coverage detected