File: account_test.go

package info (click to toggle)
golang-github-vultr-govultr 2.17.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 604 kB
  • sloc: makefile: 2
file content (48 lines) | stat: -rw-r--r-- 1,074 bytes parent folder | download
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" : "example@vultr.com",
			"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: "example@vultr.com", ACL: []string{"subscriptions", "billing", "support", "provisioning"}}

	if !reflect.DeepEqual(account, expected) {
		t.Errorf("Account.Get returned %+v, expected %+v", account, expected)
	}
}