Skip to content

Commit a971712

Browse files
test: ensure notification goes to correct users
1 parent 5732b26 commit a971712

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

enterprise/coderd/templates_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ func TestTemplates(t *testing.T) {
4747
},
4848
LicenseOptions: &coderdenttest.LicenseOptions{
4949
Features: license.Features{
50-
codersdk.FeatureAccessControl: 1,
50+
codersdk.FeatureAccessControl: 1,
51+
codersdk.FeatureMultipleOrganizations: 1,
5152
},
5253
},
5354
})
@@ -56,6 +57,9 @@ func TestTemplates(t *testing.T) {
5657
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
5758
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
5859

60+
org := coderdenttest.CreateOrganization(t, owner, coderdenttest.CreateOrganizationOptions{})
61+
_, thirdUser := coderdtest.CreateAnotherUser(t, owner, org.ID, rbac.RoleTemplateAdmin())
62+
5963
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
6064
defer cancel()
6165

@@ -85,8 +89,15 @@ func TestTemplates(t *testing.T) {
8589
}
8690
slices.Sort(sentTo)
8791

92+
// Require the notification to have only been sent to the expected users
8893
assert.Equal(t, expectedSentTo, sentTo)
8994

95+
// The previous check should verify this but we're double checking that
96+
// the notification wasn't sent to a user in another org.
97+
for _, notif := range notifs {
98+
assert.NotEqual(t, thirdUser.ID, notif.UserID)
99+
}
100+
90101
_, err = client.CreateWorkspace(ctx, user.OrganizationID, codersdk.Me, codersdk.CreateWorkspaceRequest{
91102
TemplateID: template.ID,
92103
Name: "foobar",

0 commit comments

Comments
 (0)