forked from bold-commerce/go-shopify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shop_test.go
56 lines (48 loc) · 1.63 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
48
49
50
51
52
53
54
55
56
package goshopify
import (
"fmt"
"testing"
"time"
"github.com/jarcoal/httpmock"
)
func TestShopGet(t *testing.T) {
setup()
defer teardown()
httpmock.RegisterResponder("GET", fmt.Sprintf("https://fooshop.myshopify.com/%s/shop.json", client.pathPrefix),
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", int64(690933842), shop.ID},
{"ShopOwner", "Steve Jobs", shop.ShopOwner},
{"Address1", "1 Infinite Loop", shop.Address1},
{"Name", "Apple Computers", shop.Name},
{"Email", "steve@apple.com", shop.Email},
{"HasStorefront", true, shop.HasStorefront},
{"Source", "", shop.Source},
{"GoogleAppsDomain", "", shop.GoogleAppsDomain},
{"GoogleAppsLoginEnabled", false, shop.GoogleAppsLoginEnabled},
{"MoneyInEmailsFormat", "${{amount}}", shop.MoneyInEmailsFormat},
{"MoneyWithCurrencyInEmailsFormat", "${{amount}} USD", shop.MoneyWithCurrencyInEmailsFormat},
{"EligibleForPayments", true, shop.EligibleForPayments},
{"RequiresExtraPaymentsAgreement", false, shop.RequiresExtraPaymentsAgreement},
{"PreLaunchEnabled", false, shop.PreLaunchEnabled},
}
for _, c := range cases {
if c.expected != c.actual {
t.Errorf("Shop.%v returned %v, expected %v", c.field, c.actual, c.expected)
}
}
}