(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func TestInbox(t *testing.T) { |
| 21 | t.Parallel() |
| 22 | |
| 23 | logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}).Leveled(slog.LevelDebug) |
| 24 | tests := []struct { |
| 25 | name string |
| 26 | msgID uuid.UUID |
| 27 | payload types.MessagePayload |
| 28 | expectedErr string |
| 29 | expectedRetry bool |
| 30 | }{ |
| 31 | { |
| 32 | name: "OK", |
| 33 | msgID: uuid.New(), |
| 34 | payload: types.MessagePayload{ |
| 35 | NotificationName: "test", |
| 36 | NotificationTemplateID: notifications.TemplateWorkspaceDeleted.String(), |
| 37 | UserID: "valid", |
| 38 | Actions: []types.TemplateAction{ |
| 39 | { |
| 40 | Label: "View my workspace", |
| 41 | URL: "https://coder.com/workspaces/1", |
| 42 | }, |
| 43 | }, |
| 44 | }, |
| 45 | }, |
| 46 | { |
| 47 | name: "InvalidUserID", |
| 48 | payload: types.MessagePayload{ |
| 49 | NotificationName: "test", |
| 50 | NotificationTemplateID: notifications.TemplateWorkspaceDeleted.String(), |
| 51 | UserID: "invalid", |
| 52 | Actions: []types.TemplateAction{}, |
| 53 | }, |
| 54 | expectedErr: "parse user ID", |
| 55 | expectedRetry: false, |
| 56 | }, |
| 57 | { |
| 58 | name: "InvalidTemplateID", |
| 59 | payload: types.MessagePayload{ |
| 60 | NotificationName: "test", |
| 61 | NotificationTemplateID: "invalid", |
| 62 | UserID: "valid", |
| 63 | Actions: []types.TemplateAction{}, |
| 64 | }, |
| 65 | expectedErr: "parse template ID", |
| 66 | expectedRetry: false, |
| 67 | }, |
| 68 | } |
| 69 | |
| 70 | for _, tc := range tests { |
| 71 | t.Run(tc.name, func(t *testing.T) { |
| 72 | t.Parallel() |
| 73 | |
| 74 | db, pubsub := dbtestutil.NewDB(t) |
| 75 | |
| 76 | if tc.payload.UserID == "valid" { |
| 77 | user := dbgen.User(t, db, database.User{}) |
nothing calls this directly
no test coverage detected