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

Function todoServer

internal/cmd/todo_test.go:16–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func 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
41func runTodoAdd(t *testing.T, server *httptest.Server, args ...string) (output.Response, error) {
42 t.Helper()

Callers 6

TestTodoAddPositionalFunction · 0.85
TestTodoAddShortFlagFunction · 0.85
TestTodoAddLongFlagFunction · 0.85
TestTodoAddConflictFunction · 0.85
TestTodoAddEmptyFunction · 0.85
TestTodoAddStdinFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected