Skip to content

Commit

Permalink
Merge pull request #16 from mercadopago/enhancement/update-customer-test
Browse files Browse the repository at this point in the history
Minor adjustments
  • Loading branch information
rhames07 authored Feb 16, 2024
2 parents 0251db0 + 75d80a5 commit 43d195f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions test/integration/customer/customer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package integration

import (
"context"
"fmt"
"math/rand"
"os"
"testing"

Expand All @@ -18,8 +20,7 @@ func TestCustomer(t *testing.T) {

client := customer.NewClient(cfg)

email := os.Getenv("TEST_EMAIL")
req := customer.Request{Email: email}
req := customer.Request{Email: generateEmail()}
cus, err := client.Create(context.Background(), req)
if cus == nil {
t.Error("customer can't be nil")
Expand All @@ -41,10 +42,9 @@ func TestCustomer(t *testing.T) {

client := customer.NewClient(cfg)

email := os.Getenv("TEST_EMAIL")
req := customer.SearchRequest{
Filters: map[string]string{
"email": email,
"email": generateEmail(),
},
}
res, err := client.Search(context.Background(), req)
Expand All @@ -64,8 +64,7 @@ func TestCustomer(t *testing.T) {

client := customer.NewClient(cfg)

email := os.Getenv("TEST_EMAIL")
req := customer.Request{Email: email}
req := customer.Request{Email: generateEmail()}
cus, err := client.Create(context.Background(), req)
if cus == nil {
t.Error("customer can't be nil")
Expand Down Expand Up @@ -96,8 +95,7 @@ func TestCustomer(t *testing.T) {

client := customer.NewClient(cfg)

email := os.Getenv("TEST_EMAIL")
req := customer.Request{Email: email}
req := customer.Request{Email: generateEmail()}
cus, err := client.Create(context.Background(), req)
if cus == nil {
t.Error("customer can't be nil")
Expand All @@ -121,3 +119,8 @@ func TestCustomer(t *testing.T) {
}
})
}

func generateEmail() string {
id := rand.Intn(200000 /*max*/ -100000 /*min*/) + 100000 /*min*/
return fmt.Sprintf("test_user_sdk_%[email protected]", id)
}

0 comments on commit 43d195f

Please sign in to comment.