Conditions | 1 |
Total Lines | 56 |
Code Lines | 42 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | package flutterwave |
||
114 | func TestBillsService_GetStatusVerbose(t *testing.T) { |
||
115 | // Setup |
||
116 | t.Parallel() |
||
117 | |||
118 | // Arrange |
||
119 | server := helpers.MakeTestServer(http.StatusOK, stubs.BillsGetStatusVerboseResponse()) |
||
120 | client := New(WithBaseURL(server.URL)) |
||
121 | |||
122 | // Act |
||
123 | data, response, err := client.Bills.GetStatusVerbose(context.Background(), "9300049404444") |
||
124 | |||
125 | // Assert |
||
126 | assert.Nil(t, err) |
||
127 | |||
128 | transactionDate, err := dateparse.ParseAny("2020-03-11T20:19:21.27Z") |
||
129 | assert.Nil(t, err) |
||
130 | |||
131 | assert.Equal(t, &BillsStatusVerboseResponse{ |
||
132 | Status: "success", |
||
133 | Message: "Bill status fetch successful", |
||
134 | Data: struct { |
||
135 | Currency string `json:"currency"` |
||
136 | CustomerID string `json:"customer_id"` |
||
137 | Frequency string `json:"frequency"` |
||
138 | Amount string `json:"amount"` |
||
139 | Product string `json:"product"` |
||
140 | ProductName string `json:"product_name"` |
||
141 | Commission int `json:"commission"` |
||
142 | TransactionDate time.Time `json:"transaction_date"` |
||
143 | Country string `json:"country"` |
||
144 | TxRef string `json:"tx_ref"` |
||
145 | Extra interface{} `json:"extra"` |
||
146 | ProductDetails string `json:"product_details"` |
||
147 | Status string `json:"status"` |
||
148 | }{ |
||
149 | "NGN", |
||
150 | "+23490803840303", |
||
151 | "One Time", |
||
152 | "500.0000", |
||
153 | "AIRTIME", |
||
154 | "9MOBILE", |
||
155 | 10, |
||
156 | transactionDate, |
||
157 | "NG", |
||
158 | "CF-FLYAPI-20200311081921359990", |
||
159 | nil, |
||
160 | "FLY-API-NG-AIRTIME-9MOBILE", |
||
161 | "successful", |
||
162 | }, |
||
163 | }, data) |
||
164 | |||
165 | assert.Equal(t, http.StatusOK, response.HTTPResponse.StatusCode) |
||
166 | assert.True(t, data.IsSuccessfull()) |
||
167 | |||
168 | // Teardown |
||
169 | server.Close() |
||
170 | } |
||
171 |