forked from getconversio/go-shopify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shop_test.go
47 lines (39 loc) · 1.1 KB
/
shop_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
package goshopify
import (
"testing"
"time"
"gopkg.in/jarcoal/httpmock.v1"
)
func TestShopGet(t *testing.T) {
setup()
defer teardown()
httpmock.RegisterResponder("GET", "https://fooshop.myshopify.com/admin/shop.json",
httpmock.NewBytesResponder(200, loadFixture("shop.json")))
shop, err := client.Shop.Get(nil)
if err != nil {
t.Errorf("Shop.Get returned error: %v", err)
}
// Check that dates are parsed
d := time.Date(2007, time.December, 31, 19, 00, 00, 0, time.UTC)
if !d.Equal(*shop.CreatedAt) {
t.Errorf("Shop.CreatedAt returned %+v, expected %+v", shop.CreatedAt, d)
}
// Test a few fields
cases := []struct {
field string
expected interface{}
actual interface{}
}{
{"ID", 690933842, shop.ID},
{"ShopOwner", "Steve Jobs", shop.ShopOwner},
{"Address1", "1 Infinite Loop", shop.Address1},
{"Name", "Apple Computers", shop.Name},
{"Email", "[email protected]", shop.Email},
{"HasStorefront", true, shop.HasStorefront},
}
for _, c := range cases {
if c.expected != c.actual {
t.Errorf("Shop.%v returned %v, expected %v", c.field, c.actual, c.expected)
}
}
}