MCPcopy Index your code
hub / github.com/coder/coder / TestNotifications

Function TestNotifications

coderd/provisionerdserver/provisionerdserver_test.go:4698–5029  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

4696}
4697
4698func TestNotifications(t *testing.T) {
4699 t.Parallel()
4700
4701 t.Run("Workspace deletion", func(t *testing.T) {
4702 t.Parallel()
4703
4704 tests := []struct {
4705 name string
4706 deletionReason database.BuildReason
4707 shouldNotify bool
4708 shouldSelfInitiate bool
4709 }{
4710 {
4711 name: "initiated by autodelete",
4712 deletionReason: database.BuildReasonAutodelete,
4713 shouldNotify: true,
4714 },
4715 {
4716 name: "initiated by self",
4717 deletionReason: database.BuildReasonInitiator,
4718 shouldNotify: false,
4719 shouldSelfInitiate: true,
4720 },
4721 {
4722 name: "initiated by someone else",
4723 deletionReason: database.BuildReasonInitiator,
4724 shouldNotify: true,
4725 shouldSelfInitiate: false,
4726 },
4727 }
4728
4729 for _, tc := range tests {
4730 t.Run(tc.name, func(t *testing.T) {
4731 t.Parallel()
4732
4733 ctx := context.Background()
4734 notifEnq := &notificationstest.FakeEnqueuer{}
4735
4736 srv, db, ps, pd := setup(t, false, &overrides{
4737 notificationEnqueuer: notifEnq,
4738 })
4739
4740 user := dbgen.User(t, db, database.User{})
4741 initiator := user
4742 if !tc.shouldSelfInitiate {
4743 initiator = dbgen.User(t, db, database.User{})
4744 }
4745
4746 template := dbgen.Template(t, db, database.Template{
4747 CreatedBy: user.ID,
4748 Name: "template",
4749 Provisioner: database.ProvisionerTypeEcho,
4750 OrganizationID: pd.OrganizationID,
4751 })
4752 template, err := db.GetTemplateByID(ctx, template.ID)
4753 require.NoError(t, err)
4754 file := dbgen.File(t, db, database.File{CreatedBy: user.ID})
4755 workspaceTable := dbgen.Workspace(t, db, database.WorkspaceTable{

Callers

nothing calls this directly

Calls 15

SentMethod · 0.95
UserFunction · 0.92
TemplateFunction · 0.92
FileFunction · 0.92
WorkspaceFunction · 0.92
TemplateVersionFunction · 0.92
ProvisionerJobFunction · 0.92
WorkspaceBuildFunction · 0.92
OrganizationMemberFunction · 0.92
setupFunction · 0.70
mustFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected