-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathbrand_test.go
112 lines (96 loc) · 2.77 KB
/
brand_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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package plivo
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestBrand_List(t *testing.T) {
expectResponse("brandListResponse.json", 200)
assert := require.New(t)
resp, err := client.Brand.List(BrandListParams{Limit: 2, Offset: 0})
assert.NotNil(resp)
assert.Nil(err)
assert.NotEmpty(resp.BrandResponse[0].BrandID)
cl := client.httpClient
client.httpClient = nil
brandType := "PRIVATE_PROFIT"
status := "VERIFIED"
resp, err = client.Brand.List(BrandListParams{Type: &brandType, Status: &status})
assert.NotNil(err)
assert.Nil(resp)
client.httpClient = cl
assertRequest(t, "GET", "10dlc/Brand")
}
func TestBrand_Get(t *testing.T) {
expectResponse("brandGetResponse.json", 200)
BrandID := "BRPXS6E"
assert := require.New(t)
brand, err := client.Brand.Get(BrandID)
assert.NotNil(brand)
assert.Nil(err)
assert.Equal(BrandID, brand.Brand.BrandID)
assert.NotEmpty(brand.ApiID)
cl := client.httpClient
client.httpClient = nil
brand, err = client.Brand.Get(BrandID)
assert.NotNil(err)
assert.Nil(brand)
client.httpClient = cl
assertRequest(t, "GET", "10dlc/Brand/%s", BrandID)
}
func TestBrand_Create(t *testing.T) {
expectResponse("brandCreationResponse.json", 200)
assert := require.New(t)
resp, err := client.Brand.Create(BrandCreationParams{
BrandAlias: "brand name sample",
Type: "STARTER",
ProfileUUID: "201faedc-7df9-4840-9ab1-3997ce3f7cf4",
})
assert.NotNil(resp)
assert.Nil(err)
assert.NotEmpty(resp.ApiID)
assert.NotEmpty(resp.BrandID)
cl := client.httpClient
client.httpClient = nil
resp, err = client.Brand.Create(BrandCreationParams{
BrandAlias: "brand name sample",
Type: "STARTER",
ProfileUUID: "201faedc-7df9-4840-9ab1-3997ce3f7cf4",
})
assert.NotNil(err)
assert.Nil(resp)
client.httpClient = cl
assertRequest(t, "POST", "10dlc/Brand")
}
func TestBrand_Usecase(t *testing.T) {
expectResponse("brandUsecaseResponse.json", 200)
assert := require.New(t)
BrandID := "BPL3KN9"
resp, err := client.Brand.Usecases(BrandID)
assert.NotNil(resp)
assert.Nil(err)
assert.NotEmpty(resp.Usecases[0].Code)
cl := client.httpClient
client.httpClient = nil
resp, err = client.Brand.Usecases(BrandID)
assert.NotNil(err)
assert.Nil(resp)
client.httpClient = cl
assertRequest(t, "GET", "10dlc/Brand/%s/usecases", BrandID)
}
func TestBrand_Delete(t *testing.T) {
expectResponse("brandDeleteResponse.json", 200)
BrandID := "BRPXS6E"
assert := require.New(t)
brand, err := client.Brand.Delete(BrandID)
assert.NotNil(brand)
assert.Nil(err)
assert.Equal(BrandID, brand.BrandID)
assert.NotEmpty(brand.ApiID)
cl := client.httpClient
client.httpClient = nil
brand, err = client.Brand.Delete(BrandID)
assert.NotNil(err)
assert.Nil(brand)
client.httpClient = cl
assertRequest(t, "DELETE", "10dlc/Brand/%s", BrandID)
}