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

Function TestE2E_SubagentAncestorWatch

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

Source from the content-addressed store, hash-verified

1297}
1298
1299func TestE2E_SubagentAncestorWatch(t *testing.T) {
1300 t.Parallel()
1301
1302 ctx := testutil.Context(t, testutil.WaitLong)
1303 repoDir := initTestRepo(t)
1304
1305 // Write a dirty file that the child agent will "touch".
1306 require.NoError(t, os.WriteFile(filepath.Join(repoDir, "child.go"), []byte("package child\n"), 0o600))
1307
1308 ps := agentgit.NewPathStore()
1309 parentChatID := uuid.New()
1310 childChatID := uuid.New()
1311 mClock := quartz.NewMock(t)
1312
1313 // Connect a git watch WebSocket for the PARENT chat.
1314 stream := dialGitWatchWithPathStore(t, ps, parentChatID, agentgit.WithClock(mClock))
1315 ch := stream.Chan()
1316
1317 // Simulate a tool call from the CHILD chat with the parent as
1318 // ancestor. The PathStore propagates the paths to all ancestor
1319 // chat IDs.
1320 ps.AddPaths([]uuid.UUID{childChatID, parentChatID}, []string{filepath.Join(repoDir, "child.go")})
1321
1322 // The parent's git watch connection should receive a changes
1323 // message because AddPaths notified parentChatID's subscribers.
1324 msg := recvMsg(ctx, t, ch)
1325 require.Equal(t, codersdk.WorkspaceAgentGitServerMessageTypeChanges, msg.Type)
1326 require.NotEmpty(t, msg.Repositories)
1327
1328 foundRepo := false
1329 for _, r := range msg.Repositories {
1330 if r.RepoRoot == repoDir {
1331 foundRepo = true
1332 require.Contains(t, r.UnifiedDiff, "child.go")
1333 }
1334 }
1335 require.True(t, foundRepo, "parent watcher should see repo from child's tool call")
1336}
1337
1338func TestE2E_MultipleConcurrentChatWatchers(t *testing.T) {
1339 t.Parallel()

Callers

nothing calls this directly

Calls 13

AddPathsMethod · 0.95
ContextFunction · 0.92
NewPathStoreFunction · 0.92
WithClockFunction · 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