forked from molecule-ai/molecule-core
fix(test/delegation): add CanCommunicate mock expectations
executeDelegation(sourceID, targetID) fires proxyA2ARequest which calls registry.CanCommunicate(sourceID, targetID) when source != target. Both IDs are different test fixtures (ws-source-159, ws-target-159), so the lookup fires two separate getWorkspaceRef queries: SELECT id, parent_id FROM workspaces WHERE id = $1 -- sourceID SELECT id, parent_id FROM workspaces WHERE id = $1 -- targetID expectExecuteDelegationBase only mocked the URL/status fallback query. sqlmock would fail with "unexpected query" when the CanCommunicate lookups fired — this was a silent failure because the tests never verified ExpectationWereMet on the CanCommunicate path. Fix: add two ExpectQuery rows for both parent_id lookups (both NULL, root-level siblings, allowed). Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
e05fb6911d
commit
57bf2eccc6
@ -983,7 +983,16 @@ func expectExecuteDelegationBase(mock sqlmock.Sqlmock) {
|
||||
WithArgs("dispatched", "", testSourceID, testDelegationID).
|
||||
WillReturnResult(sqlmock.NewResult(0, 1))
|
||||
|
||||
// CanCommunicate (source=target self-call is always allowed — no DB lookup needed)
|
||||
// CanCommunicate: source != target → fires two getWorkspaceRef lookups.
|
||||
// Both test fixtures have parent_id = NULL (root-level siblings) → allowed.
|
||||
// Order matches call order: source first, then target.
|
||||
mock.ExpectQuery("SELECT id, parent_id FROM workspaces WHERE id").
|
||||
WithArgs(testSourceID).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"id", "parent_id"}).AddRow(testSourceID, nil))
|
||||
mock.ExpectQuery("SELECT id, parent_id FROM workspaces WHERE id").
|
||||
WithArgs(testTargetID).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"id", "parent_id"}).AddRow(testTargetID, nil))
|
||||
|
||||
// resolveAgentURL: reads ws:{id}:url from Redis, falls back to DB for target
|
||||
mock.ExpectQuery("SELECT url, status FROM workspaces WHERE id = ").
|
||||
WithArgs(testTargetID).
|
||||
|
||||
Loading…
Reference in New Issue
Block a user