[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.
This commit is contained in:
mlsmaycon
2026-08-16 02:57:53 +00:00
parent a2be755b7d
commit e2a09a648b

View File

@@ -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"},
}))