postStart sends a POST /start request and returns the recorder.
(t *testing.T, handler http.Handler, req workspacesdk.StartProcessRequest, headers ...http.Header)
| 33 | |
| 34 | // postStart sends a POST /start request and returns the recorder. |
| 35 | func postStart(t *testing.T, handler http.Handler, req workspacesdk.StartProcessRequest, headers ...http.Header) *httptest.ResponseRecorder { |
| 36 | t.Helper() |
| 37 | |
| 38 | ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) |
| 39 | defer cancel() |
| 40 | |
| 41 | body, err := json.Marshal(req) |
| 42 | require.NoError(t, err) |
| 43 | |
| 44 | w := httptest.NewRecorder() |
| 45 | r := httptest.NewRequestWithContext(ctx, http.MethodPost, "/start", bytes.NewReader(body)) |
| 46 | for _, h := range headers { |
| 47 | for k, vals := range h { |
| 48 | for _, v := range vals { |
| 49 | r.Header.Add(k, v) |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | handler.ServeHTTP(w, r) |
| 54 | return w |
| 55 | } |
| 56 | |
| 57 | // getList sends a GET /list request and returns the recorder. |
| 58 | func getList(t *testing.T, handler http.Handler) *httptest.ResponseRecorder { |
no test coverage detected