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

Function TestInbox

coderd/notifications/dispatch/inbox_test.go:20–107  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18)
19
20func 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{})

Callers

nothing calls this directly

Calls 11

DispatcherMethod · 0.95
NewDBFunction · 0.92
UserFunction · 0.92
NewInboxHandlerFunction · 0.92
NamedMethod · 0.80
NewMethod · 0.65
RunMethod · 0.65
StringMethod · 0.45
EqualMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected