-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathhook_test.go
46 lines (38 loc) · 1.04 KB
/
hook_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
package mango
import (
"math/rand"
"strconv"
"testing"
"time"
)
func TestHookByEventType(test *testing.T) {
service := newTestService(test)
hook, err := service.HookByEventType(EventDisputeClosed)
if err != nil {
test.Fatal("Unable to get hook for event type:", err)
}
if hook.EventType != EventDisputeClosed {
test.Fatal("Mismatched event type:", hook.EventType)
}
}
func TestHook_Save(test *testing.T) {
service := newTestService(test)
test.Log("Hook creating...")
hook, err := service.NewHook(EventDisputeClosed, "http://sdfkjkdjf.com/hook/fdjsf")
if err != nil {
test.Fatal("Unable to create hook:", err)
}
if err = hook.Save(); err != nil {
test.Log("Unable to store hook:", err)
hook, err = service.HookByEventType(EventDisputeClosed)
if err != nil {
test.Fatal("Unable to get hook: ", err)
}
}
test.Log("Hook updating...")
rand.Seed(time.Now().UTC().UnixNano())
hook.Url = "http://sdfkjkdjf.com/hook/" + strconv.Itoa(rand.Int())
if err = hook.Save(); err != nil {
test.Fatal("Unable to update hook", err)
}
}