-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathinboxnotifications_internal_test.go
More file actions
49 lines (41 loc) · 1.5 KB
/
inboxnotifications_internal_test.go
File metadata and controls
49 lines (41 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package coderd
import (
"testing"
"time"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/coderd/notifications"
"github.com/coder/coder/v2/codersdk"
)
func TestInboxNotifications_ensureNotificationIcon(t *testing.T) {
t.Parallel()
tests := []struct {
name string
icon string
templateID uuid.UUID
expectedIcon string
}{
{"WorkspaceCreated", "", notifications.TemplateWorkspaceCreated, codersdk.InboxNotificationFallbackIconWorkspace},
{"UserAccountCreated", "", notifications.TemplateUserAccountCreated, codersdk.InboxNotificationFallbackIconAccount},
{"TemplateDeleted", "", notifications.TemplateTemplateDeleted, codersdk.InboxNotificationFallbackIconTemplate},
{"TestNotification", "", notifications.TemplateTestNotification, codersdk.InboxNotificationFallbackIconOther},
{"TestExistingIcon", "https://cdn.coder.com/icon_notif.png", notifications.TemplateTemplateDeleted, "https://cdn.coder.com/icon_notif.png"},
{"UnknownTemplate", "", uuid.New(), codersdk.InboxNotificationFallbackIconOther},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
notif := codersdk.InboxNotification{
ID: uuid.New(),
UserID: uuid.New(),
TemplateID: tt.templateID,
Title: "notification title",
Content: "notification content",
Icon: tt.icon,
CreatedAt: time.Now(),
}
notif = ensureNotificationIcon(notif)
require.Equal(t, tt.expectedIcon, notif.Icon)
})
}
}