--- End-to-end integration tests (PathStore → git watch pipeline) ---
(t *testing.T)
| 1260 | // --- End-to-end integration tests (PathStore → git watch pipeline) --- |
| 1261 | |
| 1262 | func TestE2E_WriteFileTriggersGitWatch(t *testing.T) { |
| 1263 | t.Parallel() |
| 1264 | |
| 1265 | ctx := testutil.Context(t, testutil.WaitLong) |
| 1266 | repoDir := initTestRepo(t) |
| 1267 | |
| 1268 | // Write a dirty file into the repo. |
| 1269 | require.NoError(t, os.WriteFile(filepath.Join(repoDir, "newfile.go"), []byte("package newfile\n"), 0o600)) |
| 1270 | |
| 1271 | ps := agentgit.NewPathStore() |
| 1272 | chatID := uuid.New() |
| 1273 | mClock := quartz.NewMock(t) |
| 1274 | |
| 1275 | // Connect the git watch WebSocket BEFORE adding any paths. |
| 1276 | stream := dialGitWatchWithPathStore(t, ps, chatID, agentgit.WithClock(mClock)) |
| 1277 | ch := stream.Chan() |
| 1278 | |
| 1279 | // Simulate what HandleWriteFile does: add a path to the |
| 1280 | // PathStore. This triggers a notification → subscribe → scan. |
| 1281 | ps.AddPaths([]uuid.UUID{chatID}, []string{filepath.Join(repoDir, "newfile.go")}) |
| 1282 | |
| 1283 | // The WebSocket should receive a changes message showing the |
| 1284 | // repo with the dirty file. |
| 1285 | msg := recvMsg(ctx, t, ch) |
| 1286 | require.Equal(t, codersdk.WorkspaceAgentGitServerMessageTypeChanges, msg.Type) |
| 1287 | require.NotEmpty(t, msg.Repositories) |
| 1288 | |
| 1289 | foundRepo := false |
| 1290 | for _, r := range msg.Repositories { |
| 1291 | if r.RepoRoot == repoDir { |
| 1292 | foundRepo = true |
| 1293 | require.Contains(t, r.UnifiedDiff, "newfile.go") |
| 1294 | } |
| 1295 | } |
| 1296 | require.True(t, foundRepo, "expected repo %s in changes message", repoDir) |
| 1297 | } |
| 1298 | |
| 1299 | func TestE2E_SubagentAncestorWatch(t *testing.T) { |
| 1300 | t.Parallel() |
nothing calls this directly
no test coverage detected