From 666fb0424aa02c826a1dfbc1f10e6ea16ed0675a Mon Sep 17 00:00:00 2001 From: meliguilhermefernandes <“guilherme.jfernandes@mercadolivre.com”> Date: Thu, 8 Feb 2024 17:16:11 -0300 Subject: [PATCH] Card token - code quality --- go.mod | 11 ++++++++++- go.sum | 10 ++++++++++ pkg/cardtoken/client.go | 3 +++ pkg/cardtoken/client_test.go | 6 ++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 83d08ca2..1b9c281b 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,13 @@ module github.com/mercadopago/sdk-go go 1.21.0 -require github.com/google/uuid v1.5.0 +require ( + github.com/google/uuid v1.5.0 + github.com/stretchr/testify v1.8.4 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum index 040e2213..53bfb8c3 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,12 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/cardtoken/client.go b/pkg/cardtoken/client.go index 7b212d4e..b607dd55 100644 --- a/pkg/cardtoken/client.go +++ b/pkg/cardtoken/client.go @@ -11,7 +11,10 @@ const ( url = "https://api.mercadopago.com/v1/card_tokens" ) +// Client contains the method to interact with the card token API. type Client interface { + // Create create a card token. + // It is a post request to the endpoint: https://api.mercadopago.com/v1/card_tokens Create(ctx context.Context, request Request) (*Response, error) } diff --git a/pkg/cardtoken/client_test.go b/pkg/cardtoken/client_test.go index f226352b..f958de28 100644 --- a/pkg/cardtoken/client_test.go +++ b/pkg/cardtoken/client_test.go @@ -9,9 +9,11 @@ import ( "reflect" "strings" "testing" + "time" "github.com/mercadopago/sdk-go/pkg/config" "github.com/mercadopago/sdk-go/pkg/internal/httpclient" + "github.com/stretchr/testify/assert" ) var ( @@ -93,3 +95,7 @@ func TestCreate(t *testing.T) { }) } } + +func Test_parseDate(t *testing.T) { + assert.IsType(t, &time.Time{}, parseDate("2024-02-08T09:05:42.725-04:00")) +}