This repository was archived by the owner on Aug 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorders_test.go
More file actions
79 lines (63 loc) · 1.72 KB
/
orders_test.go
File metadata and controls
79 lines (63 loc) · 1.72 KB
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
package workwave
import (
"fmt"
"net/http"
"net/url"
"path/filepath"
"testing"
qt "github.com/frankban/quicktest"
)
func TestOrdersList(t *testing.T) {
setup()
defer teardown()
c := qt.New(t)
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, filepath.Join("testdata", "orders-list.json"))
})
client, _ := New("api-key")
client.baseURL, _ = url.Parse(server.URL)
o, err := client.Orders.List(ctx, OrdersListInput{
TerritoryID: "territory",
Include: "assigned",
EligibleOn: "20191019",
AssignedOn: "20191018",
})
c.Assert(err, qt.IsNil)
c.Assert(len(o), qt.Equals, 7)
}
func TestOrdersGet(t *testing.T) {
setup()
defer teardown()
c := qt.New(t)
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, filepath.Join("testdata", "orders-get.json"))
})
client, _ := New("api-key")
client.baseURL, _ = url.Parse(server.URL)
o, err := client.Orders.Get(ctx, OrdersGetInput{
TerritoryID: "territory",
IDs: []string{
"4516b2e1-43dc-49a8-8bfb-7190fa60df21",
"0d56e7a3-c737-472e-bec9-e2f19d4865d3"},
})
c.Assert(err, qt.IsNil)
c.Assert(len(o), qt.Equals, 2)
}
func TestOrdersAdd(t *testing.T) {
setup()
defer teardown()
c := qt.New(t)
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, `{"requestId": "509900a5-392e-4d34-bcfe-90cc6bf3ad47"}`)
})
client, _ := New("api-key")
client.baseURL, _ = url.Parse(server.URL)
rID, err := client.Orders.Add(ctx, OrdersAddInput{
TerritoryID: "territory",
Orders: []Order{},
Strict: false,
AcceptBadGeocodes: false,
})
c.Assert(err, qt.IsNil)
c.Assert(rID, qt.Equals, "509900a5-392e-4d34-bcfe-90cc6bf3ad47")
}