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

Function TestE2E_MultipleConcurrentChatWatchers

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

Source from the content-addressed store, hash-verified

1336}
1337
1338func TestE2E_MultipleConcurrentChatWatchers(t *testing.T) {
1339 t.Parallel()
1340
1341 ctx := testutil.Context(t, testutil.WaitLong)
1342
1343 // Create two separate git repos.
1344 repoA := initTestRepo(t)
1345 repoB := initTestRepo(t)
1346 require.NoError(t, os.WriteFile(filepath.Join(repoA, "a.go"), []byte("package a\n"), 0o600))
1347 require.NoError(t, os.WriteFile(filepath.Join(repoB, "b.go"), []byte("package b\n"), 0o600))
1348
1349 ps := agentgit.NewPathStore()
1350 chatA := uuid.New()
1351 chatB := uuid.New()
1352
1353 // Pre-populate each chat with its own repo's paths.
1354 ps.AddPaths([]uuid.UUID{chatA}, []string{filepath.Join(repoA, "a.go")})
1355 ps.AddPaths([]uuid.UUID{chatB}, []string{filepath.Join(repoB, "b.go")})
1356
1357 // Connect two separate git watch WebSockets, one per chat.
1358 streamA := dialGitWatchWithPathStore(t, ps, chatA)
1359 chA := streamA.Chan()
1360
1361 streamB := dialGitWatchWithPathStore(t, ps, chatB)
1362 chB := streamB.Chan()
1363
1364 // Chat A should only see repoA.
1365 msgA := recvMsg(ctx, t, chA)
1366 require.Equal(t, codersdk.WorkspaceAgentGitServerMessageTypeChanges, msgA.Type)
1367 require.NotEmpty(t, msgA.Repositories)
1368 for _, r := range msgA.Repositories {
1369 require.Equal(t, repoA, r.RepoRoot,
1370 "chatA should only see repoA, got %s", r.RepoRoot)
1371 }
1372
1373 // Chat B should only see repoB.
1374 msgB := recvMsg(ctx, t, chB)
1375 require.Equal(t, codersdk.WorkspaceAgentGitServerMessageTypeChanges, msgB.Type)
1376 require.NotEmpty(t, msgB.Repositories)
1377 for _, r := range msgB.Repositories {
1378 require.Equal(t, repoB, r.RepoRoot,
1379 "chatB should only see repoB, got %s", r.RepoRoot)
1380 }
1381}
1382
1383func TestE2E_ReEditedFileTriggersRescan(t *testing.T) {
1384 t.Parallel()

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected