(t *testing.T)
| 915 | } |
| 916 | |
| 917 | func TestFallbackPollTriggersScan(t *testing.T) { |
| 918 | t.Parallel() |
| 919 | |
| 920 | ctx := testutil.Context(t, testutil.WaitLong) |
| 921 | repoDir := initTestRepo(t) |
| 922 | mClock := quartz.NewMock(t) |
| 923 | |
| 924 | ps := agentgit.NewPathStore() |
| 925 | chatID := uuid.New() |
| 926 | |
| 927 | require.NoError(t, os.WriteFile(filepath.Join(repoDir, "poll.go"), []byte("package poll\n"), 0o600)) |
| 928 | ps.AddPaths([]uuid.UUID{chatID}, []string{filepath.Join(repoDir, "poll.go")}) |
| 929 | |
| 930 | // Only the fallback poll can trigger scans (no filesystem |
| 931 | // watcher). |
| 932 | stream := dialGitWatchWithPathStore(t, ps, chatID, agentgit.WithClock(mClock)) |
| 933 | ch := stream.Chan() |
| 934 | |
| 935 | // We should get an initial scan from subscribe. |
| 936 | msg1 := recvMsg(ctx, t, ch) |
| 937 | require.Equal(t, codersdk.WorkspaceAgentGitServerMessageTypeChanges, msg1.Type) |
| 938 | |
| 939 | // Add a new dirty file so the next scan has a delta to report. |
| 940 | require.NoError(t, os.WriteFile(filepath.Join(repoDir, "poll2.go"), []byte("package poll\n"), 0o600)) |
| 941 | |
| 942 | // Advance to the fallback poll interval. This should trigger a |
| 943 | // scan without any explicit refresh. |
| 944 | mClock.Advance(5 * time.Second).MustWait(context.Background()) |
| 945 | |
| 946 | msg2 := recvMsg(ctx, t, ch) |
| 947 | require.Equal(t, codersdk.WorkspaceAgentGitServerMessageTypeChanges, msg2.Type) |
| 948 | require.NotEmpty(t, msg2.Repositories) |
| 949 | } |
| 950 | |
| 951 | func TestMultipleConcurrentConnections(t *testing.T) { |
| 952 | t.Parallel() |
nothing calls this directly
no test coverage detected