forked from cherryservers/cherrygo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
images_test.go
67 lines (61 loc) · 1.14 KB
/
images_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
65
66
67
package cherrygo
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestImages_List(t *testing.T) {
setup()
defer teardown()
expected := []Image{
{
ID: 1,
Name: "CloudLinux 7 64bit",
Slug: "cloudlinux_7",
Pricing: []Pricing{
{
Price: 0.015,
Taxed: false,
Currency: "EUR",
Unit: "Hourly",
},
},
},
{
ID: 2,
Name: "Ubuntu 20.04 64bit",
Slug: "ubuntu_20_04",
},
}
mux.HandleFunc("/v1/plans/e5_1620v4/images", func(writer http.ResponseWriter, request *http.Request) {
testMethod(t, request, http.MethodGet)
fmt.Fprint(writer, `[
{
"id": 1,
"name": "CloudLinux 7 64bit",
"slug": "cloudlinux_7",
"pricing": [
{
"price": 0.015,
"taxed": false,
"currency": "EUR",
"unit": "Hourly"
}
]
},
{
"id": 2,
"name": "Ubuntu 20.04 64bit",
"slug": "ubuntu_20_04"
}
]`)
})
images, _, err := client.Images.List("e5_1620v4", nil)
if err != nil {
t.Errorf("Images.List returned %+v", err)
}
if !reflect.DeepEqual(images, expected) {
t.Errorf("Images.List returned %+v, expected %+v", images, expected)
}
}