forked from keighl/postmark
-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathserver_test.go
More file actions
79 lines (71 loc) · 2.26 KB
/
server_test.go
File metadata and controls
79 lines (71 loc) · 2.26 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
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
package postmark
import (
"context"
"net/http"
)
func (s *PostmarkTestSuite) TestGetCurrentServer() {
responseJSON := `{
"ID": 1,
"Name": "Staging Testing",
"ApiTokens": [
"server token"
],
"ServerLink": "https://postmarkapp.com/servers/1/overview",
"Color": "red",
"SmtpApiActivated": true,
"RawEmailEnabled": false,
"DeliveryHookUrl": "https://hooks.example.com/delivery",
"InboundAddress": "yourhash@inbound.postmarkapp.com",
"InboundHookUrl": "https://hooks.example.com/inbound",
"BounceHookUrl": "https://hooks.example.com/bounce",
"IncludeBounceContentInHook": true,
"OpenHookUrl": "https://hooks.example.com/open",
"PostFirstOpenOnly": false,
"TrackOpens": false,
"TrackLinks" : "None",
"ClickHookUrl" : "https://hooks.example.com/click",
"InboundDomain": "",
"InboundHash": "yourhash",
"InboundSpamThreshold": 0
}`
s.mux.Get("/server", func(w http.ResponseWriter, _ *http.Request) {
_, _ = w.Write([]byte(responseJSON))
})
res, err := s.client.GetCurrentServer(context.Background())
s.Require().NoError(err)
s.Equal("Staging Testing", res.Name, "GetCurrentServer: wrong name")
}
func (s *PostmarkTestSuite) TestEditCurrentServer() {
responseJSON := `{
"ID": 1,
"Name": "Production Testing",
"ApiTokens": [
"Server Token"
],
"ServerLink": "https://postmarkapp.com/servers/1/overview",
"Color": "blue",
"SmtpApiActivated": false,
"RawEmailEnabled": false,
"DeliveryHookUrl": "https://hooks.example.com/delivery",
"InboundAddress": "yourhash@inbound.postmarkapp.com",
"InboundHookUrl": "https://hooks.example.com/inbound",
"BounceHookUrl": "https://hooks.example.com/bounce",
"IncludeBounceContentInHook": true,
"OpenHookUrl": "https://hooks.example.com/open",
"PostFirstOpenOnly": false,
"TrackOpens": false,
"TrackLinks": "None",
"ClickHookUrl": "https://hooks.example.com/click",
"InboundDomain": "",
"InboundHash": "yourhash",
"InboundSpamThreshold": 10
}`
s.mux.Put("/server", func(w http.ResponseWriter, _ *http.Request) {
_, _ = w.Write([]byte(responseJSON))
})
res, err := s.client.EditCurrentServer(context.Background(), Server{
Name: "Production Testing",
})
s.Require().NoError(err)
s.Equal("Production Testing", res.Name, "EditCurrentServer: wrong name")
}