forked from keighl/postmark
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server_test.go
90 lines (80 loc) · 2.35 KB
/
server_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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package postmark
import (
"testing"
"net/http"
"goji.io/pat"
)
func TestGetCurrentServer(t *testing.T) {
responseJSON := `{
"ID": 1,
"Name": "Staging Testing",
"ApiTokens": [
"server token"
],
"ServerLink": "https://postmarkapp.com/servers/1/overview",
"Color": "red",
"SmtpApiActivated": true,
"RawEmailEnabled": false,
"DeliveryHookUrl": "http://hooks.example.com/delivery",
"InboundAddress": "[email protected]",
"InboundHookUrl": "http://hooks.example.com/inbound",
"BounceHookUrl": "http://hooks.example.com/bounce",
"IncludeBounceContentInHook": true,
"OpenHookUrl": "http://hooks.example.com/open",
"PostFirstOpenOnly": false,
"TrackOpens": false,
"TrackLinks" : "None",
"ClickHookUrl" : "http://hooks.example.com/click",
"InboundDomain": "",
"InboundHash": "yourhash",
"InboundSpamThreshold": 0
}`
tMux.HandleFunc(pat.Get("/server"), func(w http.ResponseWriter, req *http.Request) {
w.Write([]byte(responseJSON))
})
res, err := client.GetCurrentServer()
if err != nil {
t.Fatalf("GetCurrentServer: %s", err.Error())
}
if res.Name != "Staging Testing" {
t.Fatalf("GetCurrentServer: wrong name!: %s", res.Name)
}
}
func TestEditCurrentServer(t *testing.T) {
responseJSON := `{
"ID": 1,
"Name": "Production Testing",
"ApiTokens": [
"Server Token"
],
"ServerLink": "https://postmarkapp.com/servers/1/overview",
"Color": "blue",
"SmtpApiActivated": false,
"RawEmailEnabled": false,
"DeliveryHookUrl": "http://hooks.example.com/delivery",
"InboundAddress": "[email protected]",
"InboundHookUrl": "http://hooks.example.com/inbound",
"BounceHookUrl": "http://hooks.example.com/bounce",
"IncludeBounceContentInHook": true,
"OpenHookUrl": "http://hooks.example.com/open",
"PostFirstOpenOnly": false,
"TrackOpens": false,
"TrackLinks": "None",
"ClickHookUrl": "http://hooks.example.com/click",
"InboundDomain": "",
"InboundHash": "yourhash",
"InboundSpamThreshold": 10
}`
tMux.HandleFunc(pat.Put("/server"), func(w http.ResponseWriter, req *http.Request) {
w.Write([]byte(responseJSON))
})
res, err := client.EditCurrentServer(Server{
Name: "Production Testing",
})
if err != nil {
t.Fatalf("EditCurrentServer: %s", err.Error())
}
if res.Name != "Production Testing" {
t.Fatalf("EditCurrentServer: wrong name!: %s", res.Name)
}
}