Skip to content

feat: notify on workspace creation #15934

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 6 commits into from
Dec 20, 2024
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
chore: add test
  • Loading branch information
DanielleMaywood committed Dec 18, 2024
commit a6e892a68e7042963005f3604fcbc4a9d668b14f
27 changes: 27 additions & 0 deletions coderd/workspaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,33 @@ func TestPostWorkspacesByOrganization(t *testing.T) {
require.Equal(t, http.StatusConflict, apiErr.StatusCode())
})

t.Run("CreateSendsNotification", func(t *testing.T) {
t.Parallel()

enqueuer := notificationstest.FakeEnqueuer{}
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true, NotificationsEnqueuer: &enqueuer})
user := coderdtest.CreateFirstUser(t, client)

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

workspace := coderdtest.CreateWorkspace(t, client, template.ID)
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)

var notif *notificationstest.FakeNotification
for _, n := range enqueuer.Sent() {
if n.TemplateID == notifications.TemplateWorkspaceCreated {
notif = n
break
}
}

assert.NotNil(t, notif)
assert.Equal(t, user.UserID, notif.UserID)
assert.Equal(t, notifications.TemplateWorkspaceCreated, notif.TemplateID)
})

t.Run("CreateWithAuditLogs", func(t *testing.T) {
t.Parallel()
auditor := audit.NewMock()
Expand Down
Loading