forked from bold-commerce/go-shopify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
assigned_fulfillment_order_test.go
64 lines (50 loc) · 2.18 KB
/
assigned_fulfillment_order_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
package goshopify
import (
"context"
"fmt"
"reflect"
"testing"
"github.com/jarcoal/httpmock"
)
func AssignedFulfillmentOrderTests(t *testing.T, assignedFulfillmentOrder AssignedFulfillmentOrder) {
// Check that Id is assigned to the returned fulfillment
expectedInt := uint64(255858046) // in assigned_fulfillment_orders.json fixture
if assignedFulfillmentOrder.Id != expectedInt {
t.Errorf("AssignedFulfillmentOrder.Id returned %+v, expected %+v", assignedFulfillmentOrder.Id, expectedInt)
}
}
func TestAssignedFulfillmentOrderGet(t *testing.T) {
setup()
defer teardown()
httpmock.RegisterResponder("GET", fmt.Sprintf("https://fooshop.myshopify.com/%s/assigned_fulfillment_orders.json", client.pathPrefix),
httpmock.NewStringResponder(200, `{"fulfillment_orders": [{"id":1},{"id":2}]}`))
assignedFulfillmentOrderService := &AssignedFulfillmentOrderServiceOp{client: client}
assignedFulfillmentOrders, err := assignedFulfillmentOrderService.Get(context.Background(), nil)
if err != nil {
t.Errorf("AssignedFulfillmentOrder.List returned error: %v", err)
}
expected := []AssignedFulfillmentOrder{{Id: 1}, {Id: 2}}
if !reflect.DeepEqual(assignedFulfillmentOrders, expected) {
t.Errorf("AssignedFulfillmentOrder.List returned %+v, expected %+v", assignedFulfillmentOrders, expected)
}
}
// func TestFulfillmentOrderGet(t *testing.T) {
// setup()
// defer teardown()
// fixture := loadFixture("fulfillment_order.json")
// httpmock.RegisterResponder("GET", fmt.Sprintf("https://fooshop.myshopify.com/%s/fulfillment_orders/255858046.json", client.pathPrefix),
// httpmock.NewBytesResponder(200, fixture))
// fulfillmentOrderService := &FulfillmentOrderServiceOp{client: client}
// fulfillment, err := fulfillmentOrderService.Get(context.Background(), 255858046, nil)
// if err != nil {
// t.Errorf("FulfillmentOrder.Get returned error: %v", err)
// }
// expected := FulfillmentOrderResource{}
// err = json.Unmarshal(fixture, &expected)
// if err != nil {
// t.Errorf("json.Unmarshall returned error : %v", err)
// }
// if !reflect.DeepEqual(fulfillment, expected.FulfillmentOrder) {
// t.Errorf("FulfillmentOrder.Get returned %+v, expected %+v", fulfillment, expected)
// }
// }