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

Function TestHandleAction_KeyAction

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

Source from the content-addressed store, hash-verified

466}
467
468func TestHandleAction_KeyAction(t *testing.T) {
469 t.Parallel()
470
471 logger := slogtest.Make(t, nil)
472 fake := &fakeDesktop{
473 startCfg: agentdesktop.DisplayConfig{Width: 1920, Height: 1080},
474 }
475 api := agentdesktop.NewAPI(logger, fake, nil)
476 defer api.Close()
477
478 text := "Return"
479 body := agentdesktop.DesktopAction{
480 Action: "key",
481 Text: &text,
482 }
483 b, err := json.Marshal(body)
484 require.NoError(t, err)
485
486 rr := httptest.NewRecorder()
487 req := httptest.NewRequest(http.MethodPost, "/action", bytes.NewReader(b))
488 req.Header.Set("Content-Type", "application/json")
489
490 handler := api.Routes()
491 handler.ServeHTTP(rr, req)
492
493 assert.Equal(t, http.StatusOK, rr.Code)
494 assert.Equal(t, "Return", fake.lastKey)
495}
496
497func TestHandleAction_TypeAction(t *testing.T) {
498 t.Parallel()

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
RoutesMethod · 0.95
NewAPIFunction · 0.92
SetMethod · 0.65
MarshalMethod · 0.45
ServeHTTPMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected