-
Notifications
You must be signed in to change notification settings - Fork 6
/
accounts_test.go
72 lines (66 loc) · 2.55 KB
/
accounts_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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package gorecurly
import (
"fmt"
"net/http"
"net/http/httptest"
"testing"
)
var accountGet,accountCreate string
func init(){
accountGet = `
<?xml version="1.0" encoding="UTF-8"?>
<account href="https://api.recurly.com/v2/accounts/test21">
<adjustments href="https://api.recurly.com/v2/accounts/test21/adjustments"/>
<billing_info href="https://api.recurly.com/v2/accounts/test21/billing_info"/>
<invoices href="https://api.recurly.com/v2/accounts/test21/invoices"/>
<subscriptions href="https://api.recurly.com/v2/accounts/test21/subscriptions"/>
<transactions href="https://api.recurly.com/v2/accounts/test21/transactions"/>
<account_code>test21</account_code>
<state>active</state>
<username nil="nil"></username>
<email>[email protected]</email>
<first_name>Verena</first_name>
<last_name>Example</last_name>
<company_name nil="nil"></company_name>
<accept_language>en-US,en;q=0.8</accept_language>
<hosted_login_token>1781d57cd7cfacc216314349e286ff4a</hosted_login_token>
<created_at type="datetime">2012-03-14T21:08:20Z</created_at>
</account>
`
accountCreate = `
<?xml version="1.0" encoding="UTF-8"?>
<account href="https://api.recurly.com/v2/accounts/abcdef1234567890">
<adjustments href="https://api.recurly.com/v2/accounts/abcdef1234567890/adjustments"/>
<billing_info href="https://api.recurly.com/v2/accounts/abcdef1234567890/billing_info"/>
<invoices href="https://api.recurly.com/v2/accounts/abcdef1234567890/invoices"/>
<subscriptions href="https://api.recurly.com/v2/accounts/abcdef1234567890/subscriptions"/>
<transactions href="https://api.recurly.com/v2/accounts/abcdef1234567890/transactions"/>
<account_code>abcdef1234567890</account_code>
<username>shmohawk58</username>
<email>[email protected]</email>
<first_name>Larry</first_name>
<last_name>David</last_name>
<company_name>Home Box Office</company_name>
<accept_language>en-US</accept_language>
<created_at type="datetime">2011-04-30T12:00:00Z</created_at>
</account>
`
}
func TestGetAccount(t *testing.T) {
http.HandleFunc("/accounts/test21", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "%s",accountGet)
})
ts := httptest.NewServer(nil)
defer ts.Close()
r := InitRecurly("","")
r.url = "http://" + ts.Listener.Addr().String() + "/"
if acc, e := r.GetAccount("test21"); e != nil {
t.Fatal(e.Error())
} else {
if acc.AccountCode != "test21" {
t.Fatal("Could not parse the account object correctly")
}
}
}
func TestCreate(t *testing.T) {
}