forked from vultr/govultr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
os_test.go
44 lines (37 loc) · 929 Bytes
/
os_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
package govultr
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestOSServiceHandler_List(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v2/os", func(w http.ResponseWriter, r *http.Request) {
response := `{"os":[{"id":124,"name":"Windows 2012 R2 x64","arch":"x64","family":"windows"}],"meta":{"total":27,"links":{"next":"","prev":""}}}`
fmt.Fprint(w, response)
})
os, meta, _, err := client.OS.List(ctx, nil)
if err != nil {
t.Errorf("OS.List returned error: %v", err)
}
expectedOS := []OS{
{
ID: 124,
Name: "Windows 2012 R2 x64",
Arch: "x64",
Family: "windows",
},
}
expectedMeta := &Meta{
Total: 27,
Links: &Links{},
}
if !reflect.DeepEqual(os, expectedOS) {
t.Errorf("OS.List os returned %+v, expected %+v", os, expectedOS)
}
if !reflect.DeepEqual(meta, expectedMeta) {
t.Errorf("OS.List meta returned %+v, expected %+v", meta, expectedMeta)
}
}