-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers_test.go
More file actions
42 lines (34 loc) · 910 Bytes
/
users_test.go
File metadata and controls
42 lines (34 loc) · 910 Bytes
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
package scaleway
import (
"fmt"
"net/http"
"path/filepath"
"reflect"
"testing"
)
func TestUserService_Get(t *testing.T) {
setup()
defer teardown()
client.AuthToken = "654c95b0-2cf5-41a3-b3cc-733ffba4b4b7"
data := testOpenFixture(t, filepath.Join(fixtureDir, "users_get.json"))
want := &User{
ID: "5bea0358-db40-429e-bd82-953016a7e2s7",
Email: "jsnow@got.com",
Firstname: "John",
Fullname: "John Snow",
Lastname: "Snow",
//SSHPubKeys: []string{},
}
mux.HandleFunc(fmt.Sprintf("/users/%s", want.ID), func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
w.Header().Add("Content-Type", contentType)
fmt.Fprint(w, string(data))
})
user, _, err := client.Users.Get(want.ID)
if err != nil {
t.Errorf("Users.Get returned error: %v", err)
}
if !reflect.DeepEqual(user, want) {
t.Errorf("Users.Get returned %#v\n, want %#v", user, want)
}
}