-
Notifications
You must be signed in to change notification settings - Fork 0
/
gnotifier_test.go
54 lines (42 loc) · 1.04 KB
/
gnotifier_test.go
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
50
51
52
53
54
package gnotifier
import (
"testing"
)
func Test_Notification(t *testing.T) {
n := Notification("Hey", "Hello")
if n.GetConfig().Title != "Hey" {
t.Error("NewNotification doesn't have a Title specified")
}
if n.GetConfig().Message != "Hello" {
t.Error("NewNotification doesn't have a Message specified")
}
}
func Test_Notification_Title_Validity(t *testing.T) {
n := Notification("", "Hello")
err := n.Push()
if err == nil {
t.Error("Notification should trigger an error, title is mandatory")
}
}
func Test_Notification_Message_Validity(t *testing.T) {
n := Notification("Title", "")
err := n.Push()
if err == nil {
t.Error("Notification should trigger an error, message is mandatory")
}
}
func Test_Builder_Types(t *testing.T) {
var _ Builder = Notification
var _ Builder = NullNotification
}
func Test_Records_A_Push(t *testing.T) {
r := NewTestRecorder()
var p Builder
p = r.Notification
n := p("title", "message")
n.GetConfig().Expiration = 1000
n.Push()
if len(r.Pushed) != 1 {
t.Fatal("Expected one message")
}
}