@@ -26,13 +26,16 @@ func TestCreateAccount(test *testing.T) {
2626 Code : String ("new_account" ),
2727 }
2828
29- account , _ := client .CreateAccount (body )
29+ account , err := client .CreateAccount (body )
30+ t .Assert (err , nil , "Error not expected" )
3031 t .Assert (account .Id , "abcd1234" , "account.Id" )
3132}
3233
3334func TestCreateAccountWithContext (test * testing.T ) {
3435 t := & T {test }
35- ctx , _ := context .WithTimeout (context .Background (), 20 * time .Second )
36+ ctx , cancel := context .WithTimeout (context .Background (), 20 * time .Second )
37+ defer cancel ()
38+
3639 scenario := & Scenario {
3740 T : t ,
3841 AssertRequest : func (req * http.Request ) {
@@ -51,7 +54,8 @@ func TestCreateAccountWithContext(test *testing.T) {
5154 Code : String ("new_account" ),
5255 }
5356
54- account , _ := client .CreateAccountWithContext (ctx , body )
57+ account , err := client .CreateAccountWithContext (ctx , body )
58+ t .Assert (err , nil , "Error not expected" )
5559 t .Assert (account .Id , "abcd1234" , "account.Id" )
5660}
5761
@@ -71,12 +75,12 @@ func TestListAccounts(test *testing.T) {
7175 "next": "/accounts?cursor=efgh5678%3A1588803986.0&limit=1&order=desc&sort=created_at",
7276 "data": [
7377 {
74- "id": "abcd1234",
78+ "id": "abcd1234",
7579 "first_name": "marigold",
7680 "last_name": "sunflower"
7781 },
7882 {
79- "id": "efgh5678",
83+ "id": "efgh5678",
8084 "first_name": "juniper",
8185 "last_name": "pinecone"
8286 }
@@ -103,7 +107,9 @@ func TestListAccounts(test *testing.T) {
103107
104108func TestListAccountsWithContext (test * testing.T ) {
105109 t := & T {test }
106- ctx , _ := context .WithTimeout (context .Background (), 20 * time .Second )
110+ ctx , cancel := context .WithTimeout (context .Background (), 20 * time .Second )
111+ defer cancel ()
112+
107113 scenario := & Scenario {
108114 T : t ,
109115 AssertRequest : func (req * http.Request ) {
@@ -118,12 +124,12 @@ func TestListAccountsWithContext(test *testing.T) {
118124 "next": "/accounts?cursor=efgh5678%3A1588803986.0&limit=1&order=desc&sort=created_at",
119125 "data": [
120126 {
121- "id": "abcd1234",
127+ "id": "abcd1234",
122128 "first_name": "marigold",
123129 "last_name": "sunflower"
124130 },
125131 {
126- "id": "efgh5678",
132+ "id": "efgh5678",
127133 "first_name": "juniper",
128134 "last_name": "pinecone"
129135 }
@@ -168,6 +174,7 @@ func TestCreateAccountWithNilContext(test *testing.T) {
168174 Code : String ("new_account" ),
169175 }
170176
171- account , _ := client .CreateAccountWithContext (nil , body )
177+ account , err := client .CreateAccountWithContext (context .Background (), body )
178+ t .Assert (err , nil , "Error not expected" )
172179 t .Assert (account .Id , "abcd1234" , "account.Id" )
173180}
0 commit comments