-
Notifications
You must be signed in to change notification settings - Fork 143
/
exports_test.go
46 lines (36 loc) · 1.07 KB
/
exports_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 mailgun_test
import (
"context"
"testing"
"github.com/facebookgo/ensure"
"github.com/mailgun/mailgun-go/v4"
)
func TestExports(t *testing.T) {
mg := mailgun.NewMailgun(testDomain, testKey)
mg.SetAPIBase(server.URL())
ctx := context.Background()
list, err := mg.ListExports(ctx, "")
ensure.Nil(t, err)
ensure.DeepEqual(t, len(list), 0)
err = mg.CreateExport(ctx, "/domains")
ensure.Nil(t, err)
list, err = mg.ListExports(ctx, "")
ensure.Nil(t, err)
ensure.DeepEqual(t, len(list), 1)
ensure.DeepEqual(t, list[0].ID, "0")
ensure.DeepEqual(t, list[0].URL, "/domains")
ensure.DeepEqual(t, list[0].Status, "complete")
export, err := mg.GetExport(ctx, "0")
ensure.Nil(t, err)
ensure.DeepEqual(t, export.ID, "0")
ensure.DeepEqual(t, export.URL, "/domains")
ensure.DeepEqual(t, export.Status, "complete")
}
func TestExportsLink(t *testing.T) {
mg := mailgun.NewMailgun(testDomain, testKey)
mg.SetAPIBase(server.URL())
ctx := context.Background()
url, err := mg.GetExportLink(ctx, "12")
ensure.Nil(t, err)
ensure.StringContains(t, url, "/some/s3/url")
}