forked from samkenxstream/SAMkenxgovultr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
account_test.go
48 lines (40 loc) · 1.05 KB
/
account_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
package govultr
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestAccountServiceHandler_Get(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v2/account", func(w http.ResponseWriter, r *http.Request) {
response := `
{
"account" : {
"balance": -5519.11,
"pending_charges": 57.03,
"last_payment_date": "2014-07-18 15:31:01",
"last_payment_amount": -1.00,
"name": "Test Tester",
"email" : "[email protected]",
"acls": [
"subscriptions",
"billing",
"support",
"provisioning"
]
}
}
`
fmt.Fprint(w, response)
})
account, _, err := client.Account.Get(ctx)
if err != nil {
t.Errorf("Account.Get returned error: %v", err)
}
expected := &Account{Balance: -5519.11, PendingCharges: 57.03, LastPaymentDate: "2014-07-18 15:31:01", LastPaymentAmount: -1.00, Name: "Test Tester", Email: "[email protected]", ACL: []string{"subscriptions", "billing", "support", "provisioning"}}
if !reflect.DeepEqual(account, expected) {
t.Errorf("Account.Get returned %+v, expected %+v", account, expected)
}
}