-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathintegration_test.go
80 lines (70 loc) · 1.73 KB
/
integration_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
// +build integration
package t1
import (
"log"
"os"
"reflect"
"testing"
"github.com/MediaMath/go-t1/authenticators/cookie"
"github.com/MediaMath/go-t1/models"
)
var (
iClient *Client
)
func TestGetSave_org(t *testing.T) {
var org models.Organization
meta, err := iClient.Organizations.Get(100048, &org)
if err != nil {
t.Fatalf("get org: %v", err)
}
if got, want := meta.Status, "ok"; got != want {
t.Errorf("Get org status: got %v, want %v", got, want)
}
v := reflect.ValueOf(org)
for _, field := range []string{
"Address1",
"AdXSeatAccountID",
"AllowBYOPrice",
"CreatedOn",
"ID",
"OrgType",
"Version",
} {
if isEmptyValue(v.FieldByName(field)) {
t.Errorf("Get org %v: expected non-empty", field)
}
}
meta, err = iClient.Organizations.Save(&org)
if err != nil {
t.Fatalf("Save org: %v", err)
}
if got, want := meta.Status, "ok"; got != want {
t.Errorf("Save org status: got %v, want %v", got, want)
}
}
func TestMeta_counts(t *testing.T) {
var advs []models.Advertiser
meta, err := iClient.Advertisers.List(&UserParams{PageLimit: 10}, &advs)
if err != nil {
t.Fatalf("list advs count: %v", err)
}
if got, min := meta.TotalCount, 100; got <= min {
t.Errorf("list advs total count: got %v, want at least %v", got, min)
}
if got, want := meta.Count, 10; got != want {
t.Errorf("list advs count: got %v, want %v", got, want)
}
if got, want := len(advs), 10; got != want {
t.Errorf("list advs actual: got %v, want %v", got, want)
}
}
func TestMain(m *testing.M) {
conf := cookie.GetCredentialsFromEnv()
var err error
c, err := cookie.New(conf, ProductionURL)
if err != nil {
log.Fatalf("cookie login: %v\n", err)
}
iClient = NewClient(c, conf.APIKey, ProductionURL)
os.Exit(m.Run())
}