From e2a09a648bae6ed9a20f669b7b0dc126be773b4d Mon Sep 17 00:00:00 2001 From: mlsmaycon Date: Sun, 16 Aug 2026 02:57:53 +0000 Subject: [PATCH] [management] Save account row before users in setup realstore test users.account_id is a foreign key into accounts on MySQL/Postgres, so saving users for an account that has no row fails with a constraint violation there while passing on sqlite. --- .../internals/modules/agentnetwork/setup_realstore_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/management/internals/modules/agentnetwork/setup_realstore_test.go b/management/internals/modules/agentnetwork/setup_realstore_test.go index 17a1ce095..4c43a109a 100644 --- a/management/internals/modules/agentnetwork/setup_realstore_test.go +++ b/management/internals/modules/agentnetwork/setup_realstore_test.go @@ -258,6 +258,9 @@ func TestGetSetupForUser_RealStore(t *testing.T) { require.NoError(t, s.SaveAgentNetworkProvider(ctx, provider)) require.NoError(t, s.SaveAgentNetworkPolicy(ctx, newSynthTestPolicy(provider.ID, "grp-eng", ""))) + // users.account_id is a foreign key into accounts, enforced on + // MySQL/Postgres, so the account row must exist before its users. + require.NoError(t, s.SaveAccount(ctx, &nbtypes.Account{Id: testAccountID})) require.NoError(t, s.SaveUser(ctx, &nbtypes.User{ Id: "user-in", AccountID: testAccountID, Role: nbtypes.UserRoleUser, AutoGroups: []string{"grp-eng"}, }))