8000 fix: improve error message when deleting organization with resources by brettkolodny · Pull Request #17049 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

fix: improve error message when deleting organization with resources #17049

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add dbauthz test for new query
  • Loading branch information
brettkolodny committed Mar 21, 2025
commit d193edda44ffcfd1f4172da00a74f96e7e247c7d
33 changes: 33 additions & 0 deletions coderd/database/dbauthz/dbauthz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,39 @@ func (s *MethodTestSuite) TestOrganization() {
o := dbgen.Organization(s.T(), db, database.Organization{})
check.Args(o.ID).Asserts(o, policy.ActionRead).Returns(o)
}))
s.Run("GetOrganizationResourceCountByID", s.Subtest(func(db database.Store, check *expects) {
u := dbgen.User(s.T(), db, database.User{})
o := dbgen.Organization(s.T(), db, database.Organization{})

t := dbgen.Template(s.T(), db, database.Template{
CreatedBy: u.ID,
OrganizationID: o.ID,
})
dbgen.Workspace(s.T(), db, database.WorkspaceTable{
OrganizationID: o.ID,
OwnerID: u.ID,
TemplateID: t.ID,
})
dbgen.Group(s.T(), db, database.Group{OrganizationID: o.ID})
dbgen.OrganizationMember(s.T(), db, database.OrganizationMember{
OrganizationID: o.ID,
UserID: u.ID,
})

check.Args(o.ID).Asserts(
rbac.ResourceOrganizationMember.InOrg(o.ID), policy.ActionRead,
rbac.ResourceWorkspace.InOrg(o.ID), policy.ActionRead,
rbac.ResourceGroup.InOrg(o.ID), policy.ActionRead,
rbac.ResourceTemplate.InOrg(o.ID), policy.ActionRead,
rbac.ResourceProvisionerJobs.InOrg(o.ID), policy.ActionRead,
).Returns(database.GetOrganizationResourceCountByIDRow{
WorkspaceCount: 1,
GroupCount: 1,
TemplateCount: 1,
MemberCount: 1,
ProvisionerKeyCount: 0,
})
}))
s.Run("GetDefaultOrganization", s.Subtest(func(db database.Store, check *expects) {
o, _ := db.GetDefaultOrganization(context.Background())
check.Args().Asserts(o, policy.ActionRead).Returns(o)
Expand Down
Loading
0