forked from braintree-go/braintree-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
customer_paypal_account_integration_test.go
43 lines (34 loc) · 1.05 KB
/
customer_paypal_account_integration_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
// +build integration
package braintree
import (
"context"
"reflect"
"testing"
)
func TestCustomerPayPalAccount(t *testing.T) {
t.Parallel()
ctx := context.Background()
customer, err := testGateway.Customer().Create(ctx, &CustomerRequest{})
if err != nil {
t.Fatal(err)
}
nonce := FakeNoncePayPalFuturePayment
paymentMethod, err := testGateway.PaymentMethod().Create(ctx, &PaymentMethodRequest{
CustomerId: customer.Id,
PaymentMethodNonce: nonce,
})
if err != nil {
t.Fatal(err)
}
paypalAccount := paymentMethod.(*PayPalAccount)
customerFound, err := testGateway.Customer().Find(ctx, customer.Id)
if err != nil {
t.Fatal(err)
}
if customerFound.PayPalAccounts == nil || len(customerFound.PayPalAccounts.PayPalAccount) != 1 {
t.Fatalf("Customer %#v expected to have one PayPalAccount", customerFound)
}
if !reflect.DeepEqual(customerFound.PayPalAccounts.PayPalAccount[0], paypalAccount) {
t.Fatalf("Got Customer %#v PayPalAccount %#v, want %#v", customerFound, customerFound.PayPalAccounts.PayPalAccount[0], paypalAccount)
}
}