Skip to content

feat: notify users on template deprecation #15195

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 11 commits into from
Oct 24, 2024
Prev Previous commit
Next Next commit
test: create another template+workspace
  • Loading branch information
DanielleMaywood committed Oct 24, 2024
commit c63dbff5b760f29d96b087388cbb0a98112c7b99
13 changes: 11 additions & 2 deletions enterprise/coderd/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,23 @@ func TestTemplates(t *testing.T) {
},
})
client, secondUser := coderdtest.CreateAnotherUser(t, owner, user.OrganizationID, rbac.RoleTemplateAdmin())
_, thirdUser := coderdtest.CreateAnotherUser(t, owner, user.OrganizationID, rbac.RoleTemplateAdmin())
otherClient, otherUser := coderdtest.CreateAnotherUser(t, owner, user.OrganizationID, rbac.RoleTemplateAdmin())

version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)

_ = coderdtest.CreateWorkspace(t, owner, template.ID)
_ = coderdtest.CreateWorkspace(t, client, template.ID)

// Create another template for testing that users of another template do not
// get a notification.
secondVersion := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
secondTemplate := coderdtest.CreateTemplate(t, client, user.OrganizationID, secondVersion.ID)
coderdtest.AwaitTemplateVersionJobCompleted(t, client, secondVersion.ID)

_ = coderdtest.CreateWorkspace(t, otherClient, secondTemplate.ID)

ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()

Expand Down Expand Up @@ -95,7 +104,7 @@ func TestTemplates(t *testing.T) {
// The previous check should verify this but we're double checking that
// the notification wasn't sent to users not using the template.
for _, notif := range notifs {
assert.NotEqual(t, thirdUser.ID, notif.UserID)
assert.NotEqual(t, otherUser.ID, notif.UserID)
}

_, err = client.CreateWorkspace(ctx, user.OrganizationID, codersdk.Me, codersdk.CreateWorkspaceRequest{
Expand Down
Loading