postSignal sends a POST /{id}/signal request and returns the recorder.
(t *testing.T, handler http.Handler, id string, req workspacesdk.SignalProcessRequest)
| 100 | // postSignal sends a POST /{id}/signal request and returns |
| 101 | // the recorder. |
| 102 | func postSignal(t *testing.T, handler http.Handler, id string, req workspacesdk.SignalProcessRequest) *httptest.ResponseRecorder { |
| 103 | t.Helper() |
| 104 | |
| 105 | ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) |
| 106 | defer cancel() |
| 107 | |
| 108 | body, err := json.Marshal(req) |
| 109 | require.NoError(t, err) |
| 110 | |
| 111 | w := httptest.NewRecorder() |
| 112 | r := httptest.NewRequestWithContext(ctx, http.MethodPost, fmt.Sprintf("/%s/signal", id), bytes.NewReader(body)) |
| 113 | handler.ServeHTTP(w, r) |
| 114 | return w |
| 115 | } |
| 116 | |
| 117 | // newTestAPI creates a new API with a test logger and default |
| 118 | // execer, returning the handler and API. |
no test coverage detected