Skip to content

Commit 0212d71

Browse files
committed
create a few frobulators for fetchWithPostFilter
1 parent 52dacce commit 0212d71

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

coderd/database/dbauthz/dbauthz_test.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2775,16 +2775,20 @@ func (s *MethodTestSuite) TestNotifications() {
27752775

27762776
func (s *MethodTestSuite) TestFrobulators() {
27772777
s.Run("GetFrobulators", s.Subtest(func(db database.Store, check *expects) {
2778-
user := dbgen.User(s.T(), db, database.User{})
2778+
// Pre-requisite: create two users and an organization.
2779+
u1 := dbgen.User(s.T(), db, database.User{})
2780+
u2 := dbgen.User(s.T(), db, database.User{})
27792781
org := dbgen.Organization(s.T(), db, database.Organization{})
2780-
// Create a frobulator resource.
2781-
fr := dbgen.Frobulator(s.T(), db, database.Frobulator{UserID: user.ID, OrgID: org.ID})
2782-
// Assert that calling GetFrobulators with the user and org ID records a
2783-
// read action on the above resource.
2782+
// Create a few frobulator resources: two owned by u1, one owned by u2.
2783+
fr1 := dbgen.Frobulator(s.T(), db, database.Frobulator{UserID: u1.ID, OrgID: org.ID})
2784+
fr2 := dbgen.Frobulator(s.T(), db, database.Frobulator{UserID: u1.ID, OrgID: org.ID})
2785+
_ = dbgen.Frobulator(s.T(), db, database.Frobulator{UserID: u2.ID, OrgID: org.ID})
2786+
// Assert that calling GetFrobulators with a given user and org ID records a
2787+
// read action on each of the resources owned by that user.
27842788
check.Args(database.GetFrobulatorsParams{
2785-
UserID: user.ID,
2789+
UserID: u1.ID,
27862790
OrgID: org.ID,
2787-
}).Asserts(fr, policy.ActionRead)
2791+
}).Asserts(fr1, policy.ActionRead, fr2, policy.ActionRead)
27882792
}))
27892793
s.Run("InsertFrobulator", s.Subtest(func(db database.Store, check *expects) {
27902794
user := dbgen.User(s.T(), db, database.User{})

0 commit comments

Comments
 (0)