forked from getconversio/go-shopify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme_test.go
51 lines (42 loc) · 1.03 KB
/
theme_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
package goshopify
import (
"reflect"
"testing"
"gopkg.in/jarcoal/httpmock.v1"
)
func TestThemeList(t *testing.T) {
setup()
defer teardown()
httpmock.RegisterResponder(
"GET",
"https://fooshop.myshopify.com/admin/themes.json",
httpmock.NewStringResponder(
200,
`{"themes": [{"id":1},{"id":2}]}`,
),
)
httpmock.RegisterResponder(
"GET",
"https://fooshop.myshopify.com/admin/themes.json?role=main",
httpmock.NewStringResponder(
200,
`{"themes": [{"id":1}]}`,
),
)
themes, err := client.Theme.List(nil)
if err != nil {
t.Errorf("Theme.List returned error: %v", err)
}
expected := []Theme{{ID: 1}, {ID: 2}}
if !reflect.DeepEqual(themes, expected) {
t.Errorf("Theme.List returned %+v, expected %+v", themes, expected)
}
themes, err = client.Theme.List(ThemeListOptions{Role: "main"})
if err != nil {
t.Errorf("Theme.List returned error: %v", err)
}
expected = []Theme{{ID: 1}}
if !reflect.DeepEqual(themes, expected) {
t.Errorf("Theme.List returned %+v, expected %+v", themes, expected)
}
}