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

Function TestRecordingStartStop

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

Source from the content-addressed store, hash-verified

824}
825
826func TestRecordingStartStop(t *testing.T) {
827 t.Parallel()
828
829 logger := slogtest.Make(t, nil)
830 fake := &fakeDesktop{
831 startCfg: agentdesktop.DisplayConfig{Width: 1920, Height: 1080},
832 }
833 api := agentdesktop.NewAPI(logger, fake, nil)
834 defer api.Close()
835
836 handler := api.Routes()
837
838 // Start recording.
839 startBody, err := json.Marshal(map[string]string{"recording_id": testRecIDDefault})
840 require.NoError(t, err)
841 rr := httptest.NewRecorder()
842 req := httptest.NewRequest(http.MethodPost, "/recording/start", bytes.NewReader(startBody))
843 handler.ServeHTTP(rr, req)
844 require.Equal(t, http.StatusOK, rr.Code)
845
846 // Stop recording.
847 stopBody, err := json.Marshal(map[string]string{"recording_id": testRecIDDefault})
848 require.NoError(t, err)
849 rr = httptest.NewRecorder()
850 req = httptest.NewRequest(http.MethodPost, "/recording/stop", bytes.NewReader(stopBody))
851 handler.ServeHTTP(rr, req)
852 require.Equal(t, http.StatusOK, rr.Code)
853 parts := parseMultipartParts(t, rr.Header().Get("Content-Type"), rr.Body.Bytes())
854 assert.Equal(t, []byte("fake-mp4-data-"+testRecIDDefault+"-1"), parts["video/mp4"])
855}
856
857func TestRecordingStartFails(t *testing.T) {
858 t.Parallel()

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected