forked from rpip/paystack-go
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsubscription_test.go
46 lines (39 loc) · 1.09 KB
/
subscription_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
package paystack
import "testing"
func TestSubscriptionCRUD(t *testing.T) {
cust := &Customer{
FirstName: "User123",
LastName: "AdminUser",
Email: "[email protected]",
Phone: "+23400000000000000",
}
// create the customer
customer, err := c.Customer.Create(cust)
if err != nil {
t.Errorf("CREATE Subscription Customer returned error: %v", err)
}
plan1 := &Plan{
Name: "Monthly subscription retainer",
Interval: "monthly",
Amount: 250000,
}
// create the plan
plan, err := c.Plan.Create(plan1)
if err != nil {
t.Errorf("CREATE Plan returned error: %v", err)
}
subscription1 := &SubscriptionRequest{
Customer: customer.CustomerCode,
Plan: plan.PlanCode,
}
// create the subscription
_, err = c.Subscription.Create(subscription1)
if err == nil {
t.Errorf("Expected CREATE Subscription to fail with aunthorized customer, got %+v", err)
}
// retrieve the subscription list
subscriptions, err := c.Subscription.List()
if err != nil {
t.Errorf("Expected Subscription list, got %d, returned error %v", len(subscriptions.Values), err)
}
}