Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
harakeishi committed Jun 12, 2024
1 parent 6a2fcc8 commit 92e2f9d
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions payments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,53 @@ func TestPayments(t *testing.T) {
}
})

t.Run("Auth Payment", func(t *testing.T) {
res, err := c.PaymentsIDAuthPut(ctx, api.PaymentsIDAuthPutReq{
Type: api.PaymentAuthCardPaymentsIDAuthPutReq,
PaymentAuthCard: api.PaymentAuthCard{
PayType: "Card",
AccessID: accessID,
Method: api.PaymentAuthCardMethod1,
},
},
api.PaymentsIDAuthPutParams{
ID: orderID,
})
if err != nil {
t.Fatal(err)
}
v, ok := res.(*api.PaymentsIDAuthPutOK)
if !ok {
t.Fatalf("unexpected response: %T, %#v", res, res)
}
if want := orderID; v.PaymentAuthCardResponse.ID.Value != want {
t.Errorf("want %s, got %s", want, v.PaymentAuthCardResponse.ID.Value)
}
if want := api.PaymentAuthCardResponseJobCodeAUTH; v.PaymentAuthCardResponse.JobCode.Value != want {
t.Errorf("want %s, got %s", want, v.PaymentAuthCardResponse.JobCode.Value)
}
if want := api.PaymentAuthCardResponseStatusAUTHORIZED; v.PaymentAuthCardResponse.Status.Value != want {
t.Errorf("want %s, got %s", want, v.PaymentAuthCardResponse.Status.Value)
}
paymentsIDGetRes, err := c.PaymentsIDGet(ctx, api.PaymentsIDGetParams{
ID: orderID,
PayType: "Card",
})
if err != nil {
t.Fatal(err)
}
val, ok := paymentsIDGetRes.(*api.PaymentsIDGetOK)
if !ok {
t.Fatalf("unexpected response: %T, %#v", res, res)
}
if want := orderID; val.PaymentCardResponse.ID.Value != want {
t.Errorf("want %s, got %s", want, val.PaymentCardResponse.ID.Value)
}
if want := api.PaymentCardResponseStatusAUTHORIZED; val.PaymentCardResponse.Status.Value != want {
t.Errorf("want %s, got %s", want, val.PaymentCardResponse.Status.Value)
}
})

t.Run("Get Card", func(t *testing.T) {
res, err := c.CustomersCustomerIDCardsIDGet(ctx, api.CustomersCustomerIDCardsIDGetParams{
CustomerID: customerID,
Expand Down

0 comments on commit 92e2f9d

Please sign in to comment.