(t *testing.T)
| 1732 | } |
| 1733 | |
| 1734 | func TestResolveExploreToolSnapshot(t *testing.T) { |
| 1735 | t.Parallel() |
| 1736 | |
| 1737 | db, ps := dbtestutil.NewDB(t) |
| 1738 | server := newInternalTestServer(t, db, ps, chatprovider.ProviderAPIKeys{}) |
| 1739 | |
| 1740 | user, _, _ := seedInternalChatDeps(t, db) |
| 1741 | approvedMCP := insertInternalMCPServerConfig( |
| 1742 | t, db, user.ID, "approved-"+uuid.NewString(), true, |
| 1743 | ) |
| 1744 | blockedMCP := insertInternalMCPServerConfig( |
| 1745 | t, db, user.ID, "blocked-"+uuid.NewString(), false, |
| 1746 | ) |
| 1747 | |
| 1748 | // Build parent chats in memory rather than via server.CreateChat. |
| 1749 | // resolveExploreToolSnapshot only reads ID, MCPServerIDs, PlanMode, |
| 1750 | // ParentChatID, and Mode from its parent argument, so persisting |
| 1751 | // the chats is unnecessary. Skipping CreateChat avoids waking the |
| 1752 | // background acquireLoop, which would otherwise try to dial the |
| 1753 | // fake MCP URLs and call OpenAI with the dbgen test API key. Those |
| 1754 | // side effects were the root cause of the flake tracked in |
| 1755 | // CODAGT-367. |
| 1756 | askParent := database.Chat{ |
| 1757 | ID: uuid.New(), |
| 1758 | MCPServerIDs: []uuid.UUID{approvedMCP.ID, blockedMCP.ID}, |
| 1759 | } |
| 1760 | planParent := database.Chat{ |
| 1761 | ID: uuid.New(), |
| 1762 | PlanMode: database.NullChatPlanMode{ |
| 1763 | ChatPlanMode: database.ChatPlanModePlan, |
| 1764 | Valid: true, |
| 1765 | }, |
| 1766 | MCPServerIDs: []uuid.UUID{approvedMCP.ID, blockedMCP.ID}, |
| 1767 | } |
| 1768 | |
| 1769 | subagentPlanParent := planParent |
| 1770 | subagentPlanParent.ID = uuid.New() |
| 1771 | subagentPlanParent.ParentChatID = uuid.NullUUID{UUID: uuid.New(), Valid: true} |
| 1772 | |
| 1773 | exploreParent := askParent |
| 1774 | exploreParent.ID = uuid.New() |
| 1775 | exploreParent.Mode = database.NullChatMode{ChatMode: database.ChatModeExplore, Valid: true} |
| 1776 | exploreParent.ParentChatID = uuid.NullUUID{UUID: uuid.New(), Valid: true} |
| 1777 | exploreParent.MCPServerIDs = []uuid.UUID{approvedMCP.ID} |
| 1778 | |
| 1779 | tests := []struct { |
| 1780 | name string |
| 1781 | parent database.Chat |
| 1782 | wantMCPServerIDs []uuid.UUID |
| 1783 | }{ |
| 1784 | { |
| 1785 | name: "AskModeRootSnapshotsAllExternalTools", |
| 1786 | parent: askParent, |
| 1787 | wantMCPServerIDs: []uuid.UUID{approvedMCP.ID, blockedMCP.ID}, |
| 1788 | }, |
| 1789 | { |
| 1790 | name: "PlanModeRootKeepsOnlyApprovedExternalTools", |
| 1791 | parent: planParent, |
nothing calls this directly
no test coverage detected