This repository was archived by the owner on Mar 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcharge_test.go
107 lines (99 loc) · 1.9 KB
/
charge_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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package pay
import (
"net/url"
"os"
"reflect"
"testing"
)
var (
payClient *Client
// webhook
)
func init() {
key := os.Getenv("PAY_TEST_KEY")
if key == "" {
panic("PAY_TEST_KEY must be passed")
}
payClient = NewClient(key, nil)
// set base url to staging
payClient.BaseURL, _ = url.Parse("https://api.staging.pay.busha.co")
payClient.SetWebhookSecret(os.Getenv("PAY_TEST_WH_KEY"))
// Webhooks Request
}
func TestChargeService_Cancel(t *testing.T) {
type fields struct {
client *Client
}
type args struct {
id string
}
tests := []struct {
name string
fields fields
args args
want Charge
wantErr bool
}{
{
"Fail: ref does not exist",
fields{client: payClient},
args{id: "cool"},
Charge{},
true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := &ChargeService{
client: tt.fields.client,
}
got, err := c.Cancel(tt.args.id)
if (err != nil) != tt.wantErr {
t.Errorf("ChargeService.Cancel() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("ChargeService.Cancel() = %v, want %v", got, tt.want)
}
})
}
}
func TestChargeService_List(t *testing.T) {
type fields struct {
client *Client
}
type args struct {
page int
limit int
}
tests := []struct {
name string
fields fields
args args
want []Charge
wantErr bool
}{
{
"Return Charges",
fields{client: payClient},
args{page: 1, limit: 10},
[]Charge{},
false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := &ChargeService{
client: tt.fields.client,
}
got, err := c.List(tt.args.page, tt.args.limit)
if (err != nil) != tt.wantErr {
t.Errorf("ChargeService.List() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got == nil {
t.Errorf("ChargeService.List() = %v, want %v", got, tt.want)
}
})
}
}