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

Function TestWebSocketRefreshTriggersChanges

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

Source from the content-addressed store, hash-verified

824}
825
826func TestWebSocketRefreshTriggersChanges(t *testing.T) {
827 t.Parallel()
828
829 ctx := testutil.Context(t, testutil.WaitLong)
830 repoDir := initTestRepo(t)
831 require.NoError(t, os.WriteFile(filepath.Join(repoDir, "r.go"), []byte("package r\n"), 0o600))
832
833 ps := agentgit.NewPathStore()
834 chatID := uuid.New()
835 ps.AddPaths([]uuid.UUID{chatID}, []string{filepath.Join(repoDir, "r.go")})
836
837 mClock := quartz.NewMock(t)
838 stream := dialGitWatchWithPathStore(t, ps, chatID, agentgit.WithClock(mClock))
839 ch := stream.Chan()
840
841 // Consume initial changes.
842 _ = recvMsg(ctx, t, ch)
843
844 // Advance past cooldown so the refresh scan fires immediately.
845 mClock.Advance(2 * time.Second).MustWait(context.Background())
846
847 // Modify a file, then send refresh.
848 require.NoError(t, os.WriteFile(filepath.Join(repoDir, "r2.go"), []byte("package r\n"), 0o600))
849 err := stream.Send(codersdk.WorkspaceAgentGitClientMessage{
850 Type: codersdk.WorkspaceAgentGitClientMessageTypeRefresh,
851 })
852 require.NoError(t, err)
853
854 msg := recvMsg(ctx, t, ch)
855 require.Equal(t, codersdk.WorkspaceAgentGitServerMessageTypeChanges, msg.Type)
856 require.NotEmpty(t, msg.Repositories)
857}
858
859func TestWebSocketUnknownMessageType(t *testing.T) {
860 t.Parallel()

Callers

nothing calls this directly

Calls 13

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

Tested by

no test coverage detected