-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathshops_test.go
59 lines (54 loc) · 1000 Bytes
/
shops_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
package go_printify
import (
"fmt"
"net/http"
"net/http/httptest"
"net/url"
"reflect"
"testing"
)
func TestClient_ListShops(t *testing.T) {
shops := []*Shop{
{
5432,
"My new store",
"My Sales Channel",
},
{
9876,
"My other new store",
"disconnected",
},
}
s := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
rw.WriteHeader(200)
_, _ = rw.Write([]byte(`[
{
"id": 5432,
"title": "My new store",
"sales_channel": "My Sales Channel"
},
{
"id": 9876,
"title": "My other new store",
"sales_channel": "disconnected"
}
]
`))
}))
serverUrl, _ := url.Parse(s.URL)
client := NewClient("bla")
client.BaseURL = serverUrl
defer s.Close()
shopsRes, err := client.ListShops()
if err != nil {
fmt.Println(err)
}
if !reflect.DeepEqual(shopsRes, shops) {
fmt.Println(shopsRes, shops)
t.Fail()
}
}
func TestClient_DeleteShop(t *testing.T) {
// nothing to test here really
}