-
Notifications
You must be signed in to change notification settings - Fork 56
/
application_test.go
77 lines (68 loc) · 1.41 KB
/
application_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
68
69
70
71
72
73
74
75
76
77
package govultr
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestApplicationServiceHandler_List(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v2/applications", func(w http.ResponseWriter, r *http.Request) {
response := `
{
"applications": [
{
"id": 1,
"name": "LEMP",
"short_name": "lemp",
"deploy_name": "LEMP on CentOS 6 x64",
"type": "one-click",
"vendor": "",
"image_id": ""
}
],
"meta": {
"total": 29,
"links": {
"next": "bmV4dF9fNDM=",
"prev": ""
}
}
}
`
fmt.Fprint(w, response)
})
options := &ListOptions{
PerPage: 1,
Cursor: "",
}
apps, meta, _, err := client.Application.List(ctx, options)
if err != nil {
t.Errorf("Application.List returned error: %v", err)
}
expected := []Application{
{
ID: 1,
Name: "LEMP",
ShortName: "lemp",
DeployName: "LEMP on CentOS 6 x64",
Vendor: "",
Type: "one-click",
ImageID: "",
},
}
if !reflect.DeepEqual(apps, expected) {
t.Errorf("Application.List apps returned %+v, expected %+v", apps, expected)
}
expectedMeta := &Meta{
Total: 29,
Links: &Links{
Next: "bmV4dF9fNDM=",
Prev: "",
},
}
if !reflect.DeepEqual(meta, expectedMeta) {
t.Errorf("Application.List meta returned %+v, expected %+v", meta, expectedMeta)
}
}