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

Function dialGitWatchWithPathStore

agent/agentgit/agentgit_test.go:686–710  ·  view source on GitHub ↗

dialGitWatchWithPathStore starts an httptest server backed by the given PathStore and returns a stream connected with the given chat ID. The PathStore is used to feed paths into the handler instead of client-side subscribe messages.

(
	t *testing.T,
	ps *agentgit.PathStore,
	chatID uuid.UUID,
	opts ...agentgit.Option,
)

Source from the content-addressed store, hash-verified

684// chat ID. The PathStore is used to feed paths into the handler
685// instead of client-side subscribe messages.
686func dialGitWatchWithPathStore(
687 t *testing.T,
688 ps *agentgit.PathStore,
689 chatID uuid.UUID,
690 opts ...agentgit.Option,
691) *wsjson.Stream[
692 codersdk.WorkspaceAgentGitServerMessage,
693 codersdk.WorkspaceAgentGitClientMessage,
694] {
695 t.Helper()
696 logger := slogtest.Make(t, nil)
697 api := agentgit.NewAPI(logger, ps, opts...)
698 srv := httptest.NewServer(api.Routes())
699 t.Cleanup(srv.Close)
700
701 wsURL := "ws" + srv.URL[len("http"):] + "/watch?chat_id=" + chatID.String()
702 conn, _, err := websocket.Dial(context.Background(), wsURL, nil)
703 require.NoError(t, err)
704 t.Cleanup(func() { _ = conn.Close(websocket.StatusNormalClosure, "") })
705
706 return wsjson.NewStream[
707 codersdk.WorkspaceAgentGitServerMessage,
708 codersdk.WorkspaceAgentGitClientMessage,
709 ](conn, websocket.MessageText, websocket.MessageText, logger)
710}
711
712// recvMsg reads the next server message, using the provided
713// context for the timeout instead of a raw time.After.

Calls 8

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

Tested by

no test coverage detected