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

Function TestHandleRecordingStop_NoThumbnail

agent/x/agentdesktop/api_test.go:1378–1417  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1376}
1377
1378func TestHandleRecordingStop_NoThumbnail(t *testing.T) {
1379 t.Parallel()
1380
1381 logger := slogtest.Make(t, nil)
1382 fake := &fakeDesktop{
1383 startCfg: agentdesktop.DisplayConfig{Width: 1920, Height: 1080},
1384 }
1385 api := agentdesktop.NewAPI(logger, fake, nil)
1386 defer api.Close()
1387
1388 handler := api.Routes()
1389
1390 // Start recording.
1391 recID := uuid.New().String()
1392 startBody, err := json.Marshal(map[string]string{"recording_id": recID})
1393 require.NoError(t, err)
1394 rr := httptest.NewRecorder()
1395 req := httptest.NewRequest(http.MethodPost, "/recording/start", bytes.NewReader(startBody))
1396 handler.ServeHTTP(rr, req)
1397 require.Equal(t, http.StatusOK, rr.Code)
1398
1399 // Stop recording.
1400 stopBody, err := json.Marshal(map[string]string{"recording_id": recID})
1401 require.NoError(t, err)
1402 rr = httptest.NewRecorder()
1403 req = httptest.NewRequest(http.MethodPost, "/recording/stop", bytes.NewReader(stopBody))
1404 handler.ServeHTTP(rr, req)
1405 require.Equal(t, http.StatusOK, rr.Code)
1406
1407 // Verify multipart response.
1408 ct := rr.Header().Get("Content-Type")
1409 assert.True(t, strings.HasPrefix(ct, "multipart/mixed"),
1410 "expected multipart/mixed Content-Type, got %s", ct)
1411
1412 parts := parseMultipartParts(t, ct, rr.Body.Bytes())
1413 assert.Len(t, parts, 1, "expected exactly 1 part (video only)")
1414
1415 expectedMP4 := []byte("fake-mp4-data-" + recID + "-1")
1416 assert.Equal(t, expectedMP4, parts["video/mp4"])
1417}
1418
1419func TestHandleRecordingStop_OversizedThumbnail(t *testing.T) {
1420 t.Parallel()

Callers

nothing calls this directly

Calls 13

CloseMethod · 0.95
RoutesMethod · 0.95
NewAPIFunction · 0.92
parseMultipartPartsFunction · 0.85
NewMethod · 0.65
GetMethod · 0.65
StringMethod · 0.45
MarshalMethod · 0.45
ServeHTTPMethod · 0.45
EqualMethod · 0.45
HeaderMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected