(t *testing.T)
| 824 | } |
| 825 | |
| 826 | func 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 | |
| 859 | func TestWebSocketUnknownMessageType(t *testing.T) { |
| 860 | t.Parallel() |
nothing calls this directly
no test coverage detected