mockSlidesBatchUpdateServer spins up an httptest.Server that captures the batchUpdate request body and returns a canned BatchUpdatePresentationResponse. Tests can inspect captured requests via the returned pointer.
( t *testing.T, captured *[]*slides.Request, response map[string]any, )
| 18 | // batchUpdate request body and returns a canned BatchUpdatePresentationResponse. |
| 19 | // Tests can inspect captured requests via the returned pointer. |
| 20 | func mockSlidesBatchUpdateServer( |
| 21 | t *testing.T, |
| 22 | captured *[]*slides.Request, |
| 23 | response map[string]any, |
| 24 | ) *httptest.Server { |
| 25 | t.Helper() |
| 26 | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 27 | w.Header().Set("Content-Type", "application/json") |
| 28 | if strings.HasSuffix(r.URL.Path, ":batchUpdate") && r.Method == http.MethodPost { |
| 29 | var req slides.BatchUpdatePresentationRequest |
| 30 | if err := json.NewDecoder(r.Body).Decode(&req); err == nil { |
| 31 | *captured = req.Requests |
| 32 | } |
| 33 | _ = json.NewEncoder(w).Encode(response) |
| 34 | return |
| 35 | } |
| 36 | http.NotFound(w, r) |
| 37 | })) |
| 38 | return srv |
| 39 | } |
| 40 | |
| 41 | func mockSlidesPresentationBatchUpdateServer( |
| 42 | t *testing.T, |
no test coverage detected