File: users_test.go

package info (click to toggle)
golang-github-weppos-dnsimple-go 0.0~git20160204.0.65c1ca7-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 144 kB
  • sloc: makefile: 2
file content (44 lines) | stat: -rw-r--r-- 875 bytes parent folder | download | duplicates (2)
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 dnsimple

import (
	"fmt"
	"net/http"
	"reflect"
	"testing"
)

func TestUsersService_User(t *testing.T) {
	setup()
	defer teardown()

	mux.HandleFunc("/v1/user", func(w http.ResponseWriter, r *http.Request) {
		testMethod(t, r, "GET")
		fmt.Fprint(w, `
			{
			  "user": {
				"id": 1,
				"email": "example@example.com",
				"referral_token": "referral-token",
				"api_token": "api-token",
				"domain_count": 32,
				"domain_limit": 1000,
				"login_count": 2,
				"failed_login_count": 1,
				"created_at": "2011-03-17T21:30:25.731Z",
				"updated_at": "2014-12-13T13:52:08.343Z"
			  }
			}
		`)
	})

	user, _, err := client.Users.User()

	if err != nil {
		t.Errorf("Users.User returned error: %v", err)
	}

	want := User{Id: 1, Email: "example@example.com"}
	if !reflect.DeepEqual(user, want) {
		t.Errorf("Users.User returned %+v, want %+v", user, want)
	}
}