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

Function dialGitWatch

agent/agentgit/agentgit_test.go:661–680  ·  view source on GitHub ↗

--- WebSocket end-to-end tests --- dialGitWatch starts an httptest server with the agentgit API and returns a wsjson.Stream connected to it. The server and connection are cleaned up when the test ends.

(t *testing.T, opts ...agentgit.Option)

Source from the content-addressed store, hash-verified

659// returns a wsjson.Stream connected to it. The server and connection
660// are cleaned up when the test ends.
661func dialGitWatch(t *testing.T, opts ...agentgit.Option) *wsjson.Stream[
662 codersdk.WorkspaceAgentGitServerMessage,
663 codersdk.WorkspaceAgentGitClientMessage,
664] {
665 t.Helper()
666 logger := slogtest.Make(t, nil)
667 api := agentgit.NewAPI(logger, nil, opts...)
668 srv := httptest.NewServer(api.Routes())
669 t.Cleanup(srv.Close)
670
671 wsURL := "ws" + srv.URL[len("http"):] + "/watch"
672 conn, _, err := websocket.Dial(context.Background(), wsURL, nil)
673 require.NoError(t, err)
674 t.Cleanup(func() { _ = conn.Close(websocket.StatusNormalClosure, "") })
675
676 return wsjson.NewStream[
677 codersdk.WorkspaceAgentGitServerMessage,
678 codersdk.WorkspaceAgentGitClientMessage,
679 ](conn, websocket.MessageText, websocket.MessageText, logger)
680}
681
682// dialGitWatchWithPathStore starts an httptest server backed by the
683// given PathStore and returns a stream connected with the given

Callers 1

Calls 7

RoutesMethod · 0.95
NewAPIFunction · 0.92
NewStreamFunction · 0.92
HelperMethod · 0.65
CleanupMethod · 0.65
DialMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected