mirror of
https://github.com/coder/coder.git
synced 2025-07-21 01:28:49 +00:00
test: add unit test to excercise bug when idp sync hits deleted orgs (#17405)
Deleted organizations are still attempting to sync members. This causes an error on inserting the member, and would likely cause issues later in the sync process even if that member is inserted. Deleted orgs should be skipped.
This commit is contained in:
@ -17,6 +17,7 @@ type OrganizationBuilder struct {
|
||||
t *testing.T
|
||||
db database.Store
|
||||
seed database.Organization
|
||||
delete bool
|
||||
allUsersAllowance int32
|
||||
members []uuid.UUID
|
||||
groups map[database.Group][]uuid.UUID
|
||||
@ -45,6 +46,12 @@ func (b OrganizationBuilder) EveryoneAllowance(allowance int) OrganizationBuilde
|
||||
return b
|
||||
}
|
||||
|
||||
func (b OrganizationBuilder) Deleted(deleted bool) OrganizationBuilder {
|
||||
//nolint: revive // returns modified struct
|
||||
b.delete = deleted
|
||||
return b
|
||||
}
|
||||
|
||||
func (b OrganizationBuilder) Seed(seed database.Organization) OrganizationBuilder {
|
||||
//nolint: revive // returns modified struct
|
||||
b.seed = seed
|
||||
@ -119,6 +126,17 @@ func (b OrganizationBuilder) Do() OrganizationResponse {
|
||||
}
|
||||
}
|
||||
|
||||
if b.delete {
|
||||
now := dbtime.Now()
|
||||
err = b.db.UpdateOrganizationDeletedByID(ctx, database.UpdateOrganizationDeletedByIDParams{
|
||||
UpdatedAt: now,
|
||||
ID: org.ID,
|
||||
})
|
||||
require.NoError(b.t, err)
|
||||
org.Deleted = true
|
||||
org.UpdatedAt = now
|
||||
}
|
||||
|
||||
return OrganizationResponse{
|
||||
Org: org,
|
||||
AllUsersGroup: everyone,
|
||||
|
Reference in New Issue
Block a user