forked from digitalocean/godo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
balance_test.go
44 lines (37 loc) · 884 Bytes
/
balance_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 godo
import (
"fmt"
"net/http"
"reflect"
"testing"
"time"
)
func TestBalanceGet(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v2/customers/my/balance", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
response := `
{
"month_to_date_balance": "23.44",
"account_balance": "12.23",
"month_to_date_usage": "11.21",
"generated_at": "2018-06-21T08:44:38Z"
}
`
fmt.Fprint(w, response)
})
bal, _, err := client.Balance.Get(ctx)
if err != nil {
t.Errorf("Balance.Get returned error: %v", err)
}
expected := &Balance{
MonthToDateBalance: "23.44",
AccountBalance: "12.23",
MonthToDateUsage: "11.21",
GeneratedAt: time.Date(2018, 6, 21, 8, 44, 38, 0, time.UTC),
}
if !reflect.DeepEqual(bal, expected) {
t.Errorf("Balance.Get returned %+v, expected %+v", bal, expected)
}
}