forked from mailgun/mailgun-go
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstats_test.go
More file actions
43 lines (33 loc) · 1.02 KB
/
stats_test.go
File metadata and controls
43 lines (33 loc) · 1.02 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
package mailgun
import (
"testing"
"github.com/facebookgo/ensure"
)
func TestGetStats(t *testing.T) {
mg, err := NewMailgunFromEnv()
ensure.Nil(t, err)
totalCount, stats, err := mg.GetStats(-1, -1, nil, "sent", "opened")
ensure.Nil(t, err)
t.Logf("Total Count: %d\n", totalCount)
t.Logf("Id\tEvent\tCreatedAt\tTotalCount\t\n")
for _, stat := range stats {
t.Logf("%s\t%s\t%s\t%d\t\n", stat.Id, stat.Event, stat.CreatedAt, stat.TotalCount)
}
}
func TestGetStatsTotal(t *testing.T) {
mg, err := NewMailgunFromEnv()
ensure.Nil(t, err)
statsTotal, err := mg.GetStatsTotal(nil, nil, "", "", "accepted", "delivered")
ensure.Nil(t, err)
if len(statsTotal.Stats) > 0 {
firstStatsTotal := statsTotal.Stats[0]
t.Logf("Time: %s\n", firstStatsTotal.Time)
t.Logf("Accepted Total: %d\n", firstStatsTotal.Accepted.Total)
t.Logf("Delivered Total: %d\n", firstStatsTotal.Delivered.Total)
}
}
func TestDeleteTag(t *testing.T) {
mg, err := NewMailgunFromEnv()
ensure.Nil(t, err)
ensure.Nil(t, mg.DeleteTag("newsletter"))
}