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

Function TestWebSocketMultipleRepos

agent/agentgit/agentgit_test.go:750–779  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

748}
749
750func TestWebSocketMultipleRepos(t *testing.T) {
751 t.Parallel()
752
753 ctx := testutil.Context(t, testutil.WaitLong)
754 repoA := initTestRepo(t)
755 repoB := initTestRepo(t)
756 require.NoError(t, os.WriteFile(filepath.Join(repoA, "a.go"), []byte("package a\n"), 0o600))
757 require.NoError(t, os.WriteFile(filepath.Join(repoB, "b.go"), []byte("package b\n"), 0o600))
758
759 ps := agentgit.NewPathStore()
760 chatID := uuid.New()
761 ps.AddPaths([]uuid.UUID{chatID}, []string{
762 filepath.Join(repoA, "a.go"),
763 filepath.Join(repoB, "b.go"),
764 })
765
766 stream := dialGitWatchWithPathStore(t, ps, chatID)
767 ch := stream.Chan()
768
769 msg := recvMsg(ctx, t, ch)
770 require.Equal(t, codersdk.WorkspaceAgentGitServerMessageTypeChanges, msg.Type)
771 require.Len(t, msg.Repositories, 2, "should include both repos")
772
773 roots := map[string]bool{}
774 for _, r := range msg.Repositories {
775 roots[r.RepoRoot] = true
776 }
777 require.True(t, roots[repoA], "repo A missing")
778 require.True(t, roots[repoB], "repo B missing")
779}
780
781func TestWebSocketIncrementalSubscribe(t *testing.T) {
782 t.Parallel()

Callers

nothing calls this directly

Calls 11

AddPathsMethod · 0.95
ContextFunction · 0.92
NewPathStoreFunction · 0.92
initTestRepoFunction · 0.85
recvMsgFunction · 0.85
WriteFileMethod · 0.65
NewMethod · 0.65
ChanMethod · 0.45
EqualMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected