MCPcopy Index your code
hub / github.com/coder/coder / postStart

Function postStart

agent/agentproc/api_test.go:35–55  ·  view source on GitHub ↗

postStart sends a POST /start request and returns the recorder.

(t *testing.T, handler http.Handler, req workspacesdk.StartProcessRequest, headers ...http.Header)

Source from the content-addressed store, hash-verified

33
34// postStart sends a POST /start request and returns the recorder.
35func 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.
58func getList(t *testing.T, handler http.Handler) *httptest.ResponseRecorder {

Callers 2

startAndGetIDFunction · 0.85
TestStartProcessFunction · 0.85

Calls 4

HelperMethod · 0.65
AddMethod · 0.65
MarshalMethod · 0.45
ServeHTTPMethod · 0.45

Tested by

no test coverage detected