-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbalance_service_test.go
55 lines (50 loc) · 1.34 KB
/
balance_service_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
package sendpulse_sdk_go
import (
"context"
"fmt"
"net/http"
)
func (suite *SendpulseTestSuite) TestBalanceService_GetCommon() {
suite.mux.HandleFunc("/balance/rub", func(w http.ResponseWriter, r *http.Request) {
suite.Equal(http.MethodGet, r.Method)
fmt.Fprintf(w, `{
"currency": "RUR",
"balance_currency": 0
}`)
})
balance, err := suite.client.Balance.GetBalance(context.Background(), "RUB")
suite.NoError(err)
suite.Equal("RUR", balance.Currency)
}
func (suite *SendpulseTestSuite) TestBalanceService_GetDetailed() {
suite.mux.HandleFunc("/user/balance/detail", func(w http.ResponseWriter, r *http.Request) {
suite.Equal(http.MethodGet, r.Method)
fmt.Fprintf(w, `{
"balance": {
"main": "0.00",
"bonus": "0.00",
"currency": "RUR"
},
"email": {
"tariff_name": "Подписка 500",
"finished_time": "2021-07-15 15:39:02",
"emails_left": 15000,
"maximum_subscribers": 500,
"current_subscribers": 0
},
"smtp": {
"tariff_name": "SMTP Free",
"end_date": "2020-11-08 09:33:52",
"auto_renew": 0
},
"push": {
"tariff_name": "Бесплатно 10 000",
"end_date": "2021-07-16 16:46:21",
"auto_renew": 1
}
}`)
})
balance, err := suite.client.Balance.GetDetailedBalance(context.Background())
suite.NoError(err)
suite.Equal("RUR", balance.Balance.Currency)
}