(t *testing.T)
| 5311 | } |
| 5312 | |
| 5313 | func TestGroupRemovalTrigger(t *testing.T) { |
| 5314 | t.Parallel() |
| 5315 | |
| 5316 | db, _ := dbtestutil.NewDB(t) |
| 5317 | |
| 5318 | orgA := dbgen.Organization(t, db, database.Organization{}) |
| 5319 | _, err := db.InsertAllUsersGroup(context.Background(), orgA.ID) |
| 5320 | require.NoError(t, err) |
| 5321 | |
| 5322 | orgB := dbgen.Organization(t, db, database.Organization{}) |
| 5323 | _, err = db.InsertAllUsersGroup(context.Background(), orgB.ID) |
| 5324 | require.NoError(t, err) |
| 5325 | |
| 5326 | orgs := []database.Organization{orgA, orgB} |
| 5327 | |
| 5328 | user := dbgen.User(t, db, database.User{}) |
| 5329 | extra := dbgen.User(t, db, database.User{}) |
| 5330 | users := []database.User{user, extra} |
| 5331 | |
| 5332 | groupA1 := dbgen.Group(t, db, database.Group{ |
| 5333 | OrganizationID: orgA.ID, |
| 5334 | }) |
| 5335 | groupA2 := dbgen.Group(t, db, database.Group{ |
| 5336 | OrganizationID: orgA.ID, |
| 5337 | }) |
| 5338 | |
| 5339 | groupB1 := dbgen.Group(t, db, database.Group{ |
| 5340 | OrganizationID: orgB.ID, |
| 5341 | }) |
| 5342 | groupB2 := dbgen.Group(t, db, database.Group{ |
| 5343 | OrganizationID: orgB.ID, |
| 5344 | }) |
| 5345 | |
| 5346 | groups := []database.Group{groupA1, groupA2, groupB1, groupB2} |
| 5347 | |
| 5348 | // Add users to all organizations |
| 5349 | for _, u := range users { |
| 5350 | for _, o := range orgs { |
| 5351 | dbgen.OrganizationMember(t, db, database.OrganizationMember{ |
| 5352 | OrganizationID: o.ID, |
| 5353 | UserID: u.ID, |
| 5354 | }) |
| 5355 | } |
| 5356 | } |
| 5357 | |
| 5358 | // Add users to all groups |
| 5359 | for _, u := range users { |
| 5360 | for _, g := range groups { |
| 5361 | dbgen.GroupMember(t, db, database.GroupMemberTable{ |
| 5362 | GroupID: g.ID, |
| 5363 | UserID: u.ID, |
| 5364 | }) |
| 5365 | } |
| 5366 | } |
| 5367 | |
| 5368 | // Verify user is in all groups |
| 5369 | ctx := testutil.Context(t, testutil.WaitLong) |
| 5370 | onlyGroupIDs := func(row database.GetGroupsRow) uuid.UUID { |
nothing calls this directly
no test coverage detected