(t *testing.T)
| 1218 | } |
| 1219 | |
| 1220 | func TestWebSocketLargePathStoreSubscription(t *testing.T) { |
| 1221 | t.Parallel() |
| 1222 | |
| 1223 | ctx := testutil.Context(t, testutil.WaitLong) |
| 1224 | repoDir := initTestRepo(t) |
| 1225 | |
| 1226 | // Create a dirty file so we get a response. |
| 1227 | require.NoError(t, os.WriteFile(filepath.Join(repoDir, "large.go"), []byte("package large\n"), 0o600)) |
| 1228 | |
| 1229 | ps := agentgit.NewPathStore() |
| 1230 | chatID := uuid.New() |
| 1231 | |
| 1232 | // Build a path list with 500 paths — one real repo path and 499 |
| 1233 | // long non-git paths that will be silently ignored. |
| 1234 | paths := make([]string, 500) |
| 1235 | for i := range paths { |
| 1236 | if i == 0 { |
| 1237 | paths[i] = filepath.Join(repoDir, "large.go") |
| 1238 | } else { |
| 1239 | // ~100 chars of padding. |
| 1240 | padding := filepath.Join("/tmp", t.Name(), "deep", "nested", |
| 1241 | "directory", "structure", "to", "pad", "the", "path", |
| 1242 | "even", "more", "so", "it", "is", "long", "enough", |
| 1243 | string(rune('a'+i%26))+".go") |
| 1244 | paths[i] = padding |
| 1245 | } |
| 1246 | } |
| 1247 | ps.AddPaths([]uuid.UUID{chatID}, paths) |
| 1248 | |
| 1249 | stream := dialGitWatchWithPathStore(t, ps, chatID) |
| 1250 | ch := stream.Chan() |
| 1251 | |
| 1252 | // The handler must process the large path set and respond with |
| 1253 | // changes. |
| 1254 | msg := recvMsg(ctx, t, ch) |
| 1255 | require.Equal(t, codersdk.WorkspaceAgentGitServerMessageTypeChanges, msg.Type) |
| 1256 | require.Len(t, msg.Repositories, 1) |
| 1257 | require.Equal(t, repoDir, msg.Repositories[0].RepoRoot) |
| 1258 | } |
| 1259 | |
| 1260 | // --- End-to-end integration tests (PathStore → git watch pipeline) --- |
| 1261 |
nothing calls this directly
no test coverage detected