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

Function TestWebSocketSubscribeAndReceiveChanges

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

Source from the content-addressed store, hash-verified

724}
725
726func TestWebSocketSubscribeAndReceiveChanges(t *testing.T) {
727 t.Parallel()
728
729 ctx := testutil.Context(t, testutil.WaitLong)
730 repoDir := initTestRepo(t)
731 require.NoError(t, os.WriteFile(filepath.Join(repoDir, "ws.go"), []byte("package ws\n"), 0o600))
732
733 ps := agentgit.NewPathStore()
734 chatID := uuid.New()
735
736 // Add paths before connecting so the handler picks them up on
737 // startup.
738 ps.AddPaths([]uuid.UUID{chatID}, []string{filepath.Join(repoDir, "ws.go")})
739
740 stream := dialGitWatchWithPathStore(t, ps, chatID)
741 ch := stream.Chan()
742
743 msg := recvMsg(ctx, t, ch)
744 require.Equal(t, codersdk.WorkspaceAgentGitServerMessageTypeChanges, msg.Type)
745 require.NotNil(t, msg.ScannedAt)
746 require.NotEmpty(t, msg.Repositories)
747 require.Equal(t, repoDir, msg.Repositories[0].RepoRoot)
748}
749
750func TestWebSocketMultipleRepos(t *testing.T) {
751 t.Parallel()

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected