diff --git a/.gitignore b/.gitignore index 3f6ebf9..32c274f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ -.env .DS_Store +.env .idea/ -vendor/ -covprofile +*.out /.golangci.yml +covprofile +vendor/ diff --git a/Makefile b/Makefile index 2a6a402..d288870 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,14 @@ clean: ## coverage - Get test coverage and open it in a browser coverage: - go clean -testcache && GOEXPERIMENT=nocoverageredesign go test ./tests -v -coverprofile=covprofile -coverpkg=./... && go tool cover -html=covprofile + go clean -testcache + go test -coverprofile=covprofile ./... + @statement_cov=$$(go tool cover -func=covprofile | grep total: | awk '{print substr($$NF, 1, length($$NF)-1)}'); \ + if [ $$(echo "$$statement_cov < 78.0" | bc) -eq 1 ]; then \ + echo "Tests passed but statement coverage failed with coverage: $$statement_cov"; \ + exit 1; \ + fi + go tool cover -html=covprofile ## init-examples-submodule - Initialize the examples submodule init-examples-submodule: @@ -53,7 +60,7 @@ scan: ## test - Test the project test: - go clean -testcache && go test ./tests -v + go clean -testcache && go test ./... -v ## tidy - Tidies up the vendor directory tidy: diff --git a/tests/address_test.go b/address_test.go similarity index 84% rename from tests/address_test.go rename to address_test.go index c7a2d00..fc9f13d 100644 --- a/tests/address_test.go +++ b/address_test.go @@ -1,11 +1,9 @@ -package easypost_test +package easypost import ( "errors" "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestAddressCreate() { @@ -18,7 +16,7 @@ func (c *ClientTests) TestAddressCreate() { ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Address{}), reflect.TypeOf(address)) + assert.Equal(reflect.TypeOf(&Address{}), reflect.TypeOf(address)) assert.True(strings.HasPrefix(address.ID, "adr_")) assert.Equal("388 Townsend St", address.Street1) } @@ -29,13 +27,13 @@ func (c *ClientTests) TestAddressCreateVerifyStrict() { address, err := client.CreateAddress( c.fixture.CaAddress1(), - &easypost.CreateAddressOptions{ + &CreateAddressOptions{ VerifyStrict: true, }, ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Address{}), reflect.TypeOf(address)) + assert.Equal(reflect.TypeOf(&Address{}), reflect.TypeOf(address)) assert.True(strings.HasPrefix(address.ID, "adr_")) assert.Equal("388 TOWNSEND ST APT 20", address.Street1) } @@ -53,7 +51,7 @@ func (c *ClientTests) TestAddressRetrieve() { retrievedAddress, err := client.GetAddress(address.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Address{}), reflect.TypeOf(retrievedAddress)) + assert.Equal(reflect.TypeOf(&Address{}), reflect.TypeOf(retrievedAddress)) assert.Equal(address, retrievedAddress) } @@ -62,7 +60,7 @@ func (c *ClientTests) TestAddressAll() { assert, require := c.Assert(), c.Require() addresses, err := client.ListAddresses( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -71,7 +69,7 @@ func (c *ClientTests) TestAddressAll() { assert.LessOrEqual(len(addresses.Addresses), c.fixture.pageSize()) assert.NotNil(addresses.HasMore) for _, address := range addresses.Addresses { - assert.Equal(reflect.TypeOf(&easypost.Address{}), reflect.TypeOf(address)) + assert.Equal(reflect.TypeOf(&Address{}), reflect.TypeOf(address)) } } @@ -80,7 +78,7 @@ func (c *ClientTests) TestAddressGetNextPage() { assert, require := c.Assert(), c.Require() firstPage, err := client.ListAddresses( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -98,7 +96,7 @@ func (c *ClientTests) TestAddressGetNextPage() { } }() if err != nil { - var endOfPaginationErr *easypost.EndOfPaginationError + var endOfPaginationErr *EndOfPaginationError if errors.As(err, &endOfPaginationErr) { assert.Equal(err.Error(), endOfPaginationErr.Error()) return @@ -114,14 +112,14 @@ func (c *ClientTests) TestAddressCreateVerify() { address, err := client.CreateAddress( c.fixture.IncorrectAddress(), - &easypost.CreateAddressOptions{ + &CreateAddressOptions{ Verify: true, }, ) // Does return an address from CreateAddress even if requested verification fails require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Address{}), reflect.TypeOf(address)) + assert.Equal(reflect.TypeOf(&Address{}), reflect.TypeOf(address)) // Delivery verification assertions deliveryVerification := address.Verifications.Delivery @@ -151,17 +149,17 @@ func (c *ClientTests) TestAddressCreateAndVerify() { // Creating normally (without specifying "verify") will make the address, perform no verifications address, err := client.CreateAddress( c.fixture.IncorrectAddress(), - &easypost.CreateAddressOptions{}, + &CreateAddressOptions{}, ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Address{}), reflect.TypeOf(address)) + assert.Equal(reflect.TypeOf(&Address{}), reflect.TypeOf(address)) assert.Nil(address.Verifications.Delivery) // Creating with verify would attempt to make the address and perform verifications address, err = client.CreateAndVerifyAddress( c.fixture.IncorrectAddress(), - &easypost.CreateAddressOptions{ + &CreateAddressOptions{ Verify: true, }, ) @@ -184,7 +182,7 @@ func (c *ClientTests) TestAddressVerify() { verifiedAddress, err := client.VerifyAddress(address.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Address{}), reflect.TypeOf(verifiedAddress)) + assert.Equal(reflect.TypeOf(&Address{}), reflect.TypeOf(verifiedAddress)) assert.True(strings.HasPrefix(verifiedAddress.ID, "adr_")) assert.Equal("388 TOWNSEND ST APT 20", verifiedAddress.Street1) } @@ -196,14 +194,14 @@ func (c *ClientTests) TestAddressCreateVerifyCarrier() { address, err := client.CreateAddress( c.fixture.IncorrectAddress(), - &easypost.CreateAddressOptions{ + &CreateAddressOptions{ Verify: true, VerifyCarrier: "UPS", }, ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Address{}), reflect.TypeOf(address)) + assert.Equal(reflect.TypeOf(&Address{}), reflect.TypeOf(address)) deliveryVerification := address.Verifications.Delivery deliveryError := deliveryVerification.Errors[0] @@ -220,13 +218,13 @@ func (c *ClientTests) TestAddressCreateAndVerifyCarrier() { address, err := client.CreateAndVerifyAddress( c.fixture.IncorrectAddress(), - &easypost.CreateAddressOptions{ + &CreateAddressOptions{ VerifyCarrier: "UPS", }, ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Address{}), reflect.TypeOf(address)) + assert.Equal(reflect.TypeOf(&Address{}), reflect.TypeOf(address)) deliveryVerification := address.Verifications.Delivery deliveryError := deliveryVerification.Errors[0] diff --git a/tests/api_key_test.go b/api_key_test.go similarity index 84% rename from tests/api_key_test.go rename to api_key_test.go index 3d8422f..e085abf 100644 --- a/tests/api_key_test.go +++ b/api_key_test.go @@ -1,9 +1,7 @@ -package easypost_test +package easypost import ( "reflect" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestApiKeysAll() { @@ -39,5 +37,5 @@ func (c *ClientTests) TestApiKeysForChildUser() { require.Error(err) assert.Nil(apiKeys) - assert.Equal(reflect.TypeOf(&easypost.FilteringError{}), reflect.TypeOf(err)) + assert.Equal(reflect.TypeOf(&FilteringError{}), reflect.TypeOf(err)) } diff --git a/tests/batch_test.go b/batch_test.go similarity index 86% rename from tests/batch_test.go rename to batch_test.go index f08ac4a..12ca3f5 100644 --- a/tests/batch_test.go +++ b/batch_test.go @@ -1,4 +1,4 @@ -package easypost_test +package easypost import ( "errors" @@ -7,8 +7,6 @@ import ( "reflect" "strings" "time" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestBatchCreate() { @@ -20,7 +18,7 @@ func (c *ClientTests) TestBatchCreate() { ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Batch{}), reflect.TypeOf(batch)) + assert.Equal(reflect.TypeOf(&Batch{}), reflect.TypeOf(batch)) assert.True(strings.HasPrefix(batch.ID, "batch_")) assert.NotNil(batch.Shipments) } @@ -37,7 +35,7 @@ func (c *ClientTests) TestBatchRetrieve() { retrievedBatch, err := client.GetBatch(batch.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Batch{}), reflect.TypeOf(retrievedBatch)) + assert.Equal(reflect.TypeOf(&Batch{}), reflect.TypeOf(retrievedBatch)) assert.Equal(batch.ID, retrievedBatch.ID) } @@ -46,7 +44,7 @@ func (c *ClientTests) TestBatchAll() { assert, require := c.Assert(), c.Require() batches, err := client.ListBatches( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -55,7 +53,7 @@ func (c *ClientTests) TestBatchAll() { assert.LessOrEqual(len(batches.Batch), c.fixture.pageSize()) assert.NotNil(batches.HasMore) for _, batch := range batches.Batch { - assert.Equal(reflect.TypeOf(&easypost.Batch{}), reflect.TypeOf(batch)) + assert.Equal(reflect.TypeOf(&Batch{}), reflect.TypeOf(batch)) } } @@ -71,7 +69,7 @@ func (c *ClientTests) TestBatchBuy() { boughtBatch, err := client.BuyBatch(batch.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Batch{}), reflect.TypeOf(boughtBatch)) + assert.Equal(reflect.TypeOf(&Batch{}), reflect.TypeOf(boughtBatch)) assert.Equal(1, boughtBatch.NumShipments) } @@ -97,7 +95,7 @@ func (c *ClientTests) TestBatchCreateScanForm() { require.NoError(err) // We can't assert anything meaningful here because the scanform gets queued for generation and may not be immediately available - assert.Equal(reflect.TypeOf(&easypost.Batch{}), reflect.TypeOf(batchWithScanForm)) + assert.Equal(reflect.TypeOf(&Batch{}), reflect.TypeOf(batchWithScanForm)) } func (c *ClientTests) TestBatchAddRemoveShipment() { @@ -145,5 +143,5 @@ func (c *ClientTests) TestBatchLabel() { require.NoError(err) // We can't assert anything meaningful here because the label gets queued for generation and may not be immediately available - assert.Equal(reflect.TypeOf(&easypost.Batch{}), reflect.TypeOf(batchWithLabel)) + assert.Equal(reflect.TypeOf(&Batch{}), reflect.TypeOf(batchWithLabel)) } diff --git a/tests/billing_test.go b/billing_test.go similarity index 70% rename from tests/billing_test.go rename to billing_test.go index fed6bc4..5245610 100644 --- a/tests/billing_test.go +++ b/billing_test.go @@ -1,55 +1,53 @@ -package easypost_test +package easypost -import "github.com/EasyPost/easypost-go/v5" - -func GetBillingMockRequests() []easypost.MockRequest { - return []easypost.MockRequest{ +func GetBillingMockRequests() []MockRequest { + return []MockRequest{ { - MatchRule: easypost.MockRequestMatchRule{ + MatchRule: MockRequestMatchRule{ Method: "POST", UrlRegexPattern: "v2\\/bank_accounts\\/\\S*\\/charges$", }, - ResponseInfo: easypost.MockRequestResponseInfo{ + ResponseInfo: MockRequestResponseInfo{ StatusCode: 200, Body: `{}`, }, }, { - MatchRule: easypost.MockRequestMatchRule{ + MatchRule: MockRequestMatchRule{ Method: "POST", UrlRegexPattern: "v2\\/credit_cards\\/\\S*\\/charges$", }, - ResponseInfo: easypost.MockRequestResponseInfo{ + ResponseInfo: MockRequestResponseInfo{ StatusCode: 200, Body: `{}`, }, }, { - MatchRule: easypost.MockRequestMatchRule{ + MatchRule: MockRequestMatchRule{ Method: "DELETE", UrlRegexPattern: "v2\\/bank_accounts\\/\\S*$", }, - ResponseInfo: easypost.MockRequestResponseInfo{ + ResponseInfo: MockRequestResponseInfo{ StatusCode: 200, Body: `{}`, }, }, { - MatchRule: easypost.MockRequestMatchRule{ + MatchRule: MockRequestMatchRule{ Method: "DELETE", UrlRegexPattern: "v2\\/credit_cards\\/\\S*$", }, - ResponseInfo: easypost.MockRequestResponseInfo{ + ResponseInfo: MockRequestResponseInfo{ StatusCode: 200, Body: `{}`, }, }, { - MatchRule: easypost.MockRequestMatchRule{ + MatchRule: MockRequestMatchRule{ Method: "GET", UrlRegexPattern: "v2\\/payment_methods$", }, - ResponseInfo: easypost.MockRequestResponseInfo{ + ResponseInfo: MockRequestResponseInfo{ StatusCode: 200, Body: `{"id": "summary_123", "primary_payment_method": {"id": "pm_123", "object": "CreditCard", "last4": "1234"}, "secondary_payment_method": {"id": "pm_123", "object": "BankAccount", "bank_name": "Mock Bank"}}`, }, @@ -63,7 +61,7 @@ func (c *ClientTests) TestDeletePaymentMethod() { client := c.MockClient(mockRequests) require := c.Require() - err := client.DeletePaymentMethod(easypost.PrimaryPaymentMethodPriority) + err := client.DeletePaymentMethod(PrimaryPaymentMethodPriority) require.NoError(err) } @@ -73,7 +71,7 @@ func (c *ClientTests) TestFundWallet() { client := c.MockClient(mockRequests) require := c.Require() - err := client.FundWallet("2000", easypost.PrimaryPaymentMethodPriority) + err := client.FundWallet("2000", PrimaryPaymentMethodPriority) require.NoError(err) } @@ -91,23 +89,23 @@ func (c *ClientTests) TestRetrievePaymentMethods() { } func (c *ClientTests) TestGetPaymentMethodInfoByObjectType() { - mockRequests := []easypost.MockRequest{ + mockRequests := []MockRequest{ { - MatchRule: easypost.MockRequestMatchRule{ + MatchRule: MockRequestMatchRule{ Method: "GET", UrlRegexPattern: "v2\\/payment_methods$", }, - ResponseInfo: easypost.MockRequestResponseInfo{ + ResponseInfo: MockRequestResponseInfo{ StatusCode: 200, Body: `{"id": "summary_123", "primary_payment_method": {"id": "pm_123", "object": "CreditCard"}, "secondary_payment_method": {"id": "pm_123", "object": "BankAccount"}}`, }, }, { - MatchRule: easypost.MockRequestMatchRule{ + MatchRule: MockRequestMatchRule{ Method: "DELETE", UrlRegexPattern: "v2\\/credit_cards\\/pm_123$", }, - ResponseInfo: easypost.MockRequestResponseInfo{ + ResponseInfo: MockRequestResponseInfo{ StatusCode: 200, Body: `{}`, }, @@ -120,6 +118,6 @@ func (c *ClientTests) TestGetPaymentMethodInfoByObjectType() { // getPaymentMethodObjectType is a private method, so we can't test it directly, but we can test it via DeletePaymentMethod // The mocking setup here makes it so only /v2/credit_cards/pm_123 is allowed to be called // If the method works correctly without error, we can assume it's because it found the correct payment method type - err := client.DeletePaymentMethod(easypost.PrimaryPaymentMethodPriority) + err := client.DeletePaymentMethod(PrimaryPaymentMethodPriority) require.NoError(err) } diff --git a/tests/bootstrap_test.go b/bootstrap_test.go similarity index 90% rename from tests/bootstrap_test.go rename to bootstrap_test.go index f3d0201..7f6b8ee 100644 --- a/tests/bootstrap_test.go +++ b/bootstrap_test.go @@ -1,4 +1,4 @@ -package easypost_test +package easypost import ( "bytes" @@ -13,7 +13,6 @@ import ( "testing" "time" - "github.com/EasyPost/easypost-go/v5" "github.com/dnaeon/go-vcr/cassette" "github.com/dnaeon/go-vcr/recorder" "github.com/stretchr/testify/suite" @@ -251,38 +250,38 @@ func (c *ClientTests) TearDownTest() { } // TestClient sets up the test mode client object to be used in the test -func (c *ClientTests) TestClient() *easypost.Client { - return &easypost.Client{ +func (c *ClientTests) TestClient() *Client { + return &Client{ APIKey: TestAPIKey, Client: &http.Client{Transport: c.recorder}, } } // ProdClient sets up the prod mode client object to be used in the test -func (c *ClientTests) ProdClient() *easypost.Client { - return &easypost.Client{ +func (c *ClientTests) ProdClient() *Client { + return &Client{ APIKey: ProdAPIKey, Client: &http.Client{Transport: c.recorder}, } } // PartnerClient sets up the partner user client object to be used in the test -func (c *ClientTests) PartnerClient() *easypost.Client { +func (c *ClientTests) PartnerClient() *Client { if len(PartnerAPIKey) == 0 { PartnerAPIKey = "123" } - return &easypost.Client{ + return &Client{ APIKey: PartnerAPIKey, Client: &http.Client{Transport: c.recorder}, } } // ReferralClient sets up the referral customer client object to be used in the test -func (c *ClientTests) ReferralClient() *easypost.Client { +func (c *ClientTests) ReferralClient() *Client { if len(ReferralAPIKey) == 0 { ReferralAPIKey = "123" } - return &easypost.Client{ + return &Client{ APIKey: ReferralAPIKey, Client: &http.Client{Transport: c.recorder}, } @@ -297,8 +296,8 @@ func (c *ClientTests) ReferralAPIKey() string { } // MockClient sets up the mock client object to be used in the test -func (c *ClientTests) MockClient(requests []easypost.MockRequest) *easypost.Client { - return &easypost.Client{ +func (c *ClientTests) MockClient(requests []MockRequest) *Client { + return &Client{ APIKey: "cannot_be_blank", Client: &http.Client{Transport: c.recorder}, MockRequests: requests, @@ -345,17 +344,6 @@ func TestMain(m *testing.M) { flag.Parse() testSuite := m.Run() - // Fail test suite below desired coverage - // `testSuite = 0` means it passed, CoverMode will be non-empty if run with -cover - coverageMinPercentage := 0.72 // TODO: This number for whatever reason is about ~5% lower than what the CLI reports which is the real value - if testSuite == 0 && testing.CoverMode() != "" { - coverage := testing.Coverage() - if coverage < coverageMinPercentage { - fmt.Println("Tests passed but coverage failed with coverage: ", coverage) - testSuite = -1 - } - } - // Exit once tests complete os.Exit(testSuite) } diff --git a/tests/carrier_account_test.go b/carrier_account_test.go similarity index 74% rename from tests/carrier_account_test.go rename to carrier_account_test.go index b102c27..60fe5e0 100644 --- a/tests/carrier_account_test.go +++ b/carrier_account_test.go @@ -1,14 +1,12 @@ -package easypost_test +package easypost import ( "errors" "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) -func (c *ClientTests) GenerateCarrierAccount() (*easypost.CarrierAccount, error) { +func (c *ClientTests) GenerateCarrierAccount() (*CarrierAccount, error) { client := c.ProdClient() carrierAccount, err := client.CreateCarrierAccount(c.fixture.BasicCarrierAccount()) @@ -23,7 +21,7 @@ func (c *ClientTests) TestCarrierAccountCreate() { carrierAccount, err := c.GenerateCarrierAccount() require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.CarrierAccount{}), reflect.TypeOf(carrierAccount)) + assert.Equal(reflect.TypeOf(&CarrierAccount{}), reflect.TypeOf(carrierAccount)) assert.True(strings.HasPrefix(carrierAccount.ID, "ca_")) assert.Equal("DhlEcsAccount", carrierAccount.Type) @@ -47,13 +45,13 @@ func (c *ClientTests) TestCarrierAccountCreateWithCustomWorkflow() { // FedExAcc // We're sending bad data to the API, so we expect an error require.Error(err) - var invalidRequestError *easypost.InvalidRequestError + var invalidRequestError *InvalidRequestError if errors.As(err, &invalidRequestError) { - assert.Equal(reflect.TypeOf(&easypost.InvalidRequestError{}), reflect.TypeOf(err)) + assert.Equal(reflect.TypeOf(&InvalidRequestError{}), reflect.TypeOf(err)) assert.Equal(422, invalidRequestError.StatusCode) // We expect one of the sub-errors to be regarding a missing field if errorsList, ok := invalidRequestError.Errors.([]interface{}); ok { - if fieldError, ok := errorsList[0].(*easypost.FieldError); ok { + if fieldError, ok := errorsList[0].(*FieldError); ok { assert.Equal("shipping_streets", fieldError.Field) assert.Equal("must be present and a string", fieldError.Message) } @@ -71,14 +69,14 @@ func (c *ClientTests) TestCarrierAccountPreventUsersUsingUpsAccountForGenericCre _, err := client.CreateCarrierAccount(createParameters) require.Error(err) - assert.Equal(reflect.TypeOf(&easypost.InvalidFunctionError{}), reflect.TypeOf(err)) + assert.Equal(reflect.TypeOf(&InvalidFunctionError{}), reflect.TypeOf(err)) } func (c *ClientTests) TestCarrierAccountCreateUps() { client := c.ProdClient() assert, require := c.Assert(), c.Require() - createParameters := &easypost.UpsCarrierAccountCreationParameters{ + createParameters := &UpsCarrierAccountCreationParameters{ AccountNumber: "123456789", Type: "UpsAccount", } @@ -86,7 +84,7 @@ func (c *ClientTests) TestCarrierAccountCreateUps() { carrierAccount, err := client.CreateUpsCarrierAccount(createParameters) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.CarrierAccount{}), reflect.TypeOf(carrierAccount)) + assert.Equal(reflect.TypeOf(&CarrierAccount{}), reflect.TypeOf(carrierAccount)) assert.True(strings.HasPrefix(carrierAccount.ID, "ca_")) assert.Equal("UpsAccount", carrierAccount.Type) @@ -98,7 +96,7 @@ func (c *ClientTests) TestCarrierAccountPreventUsersUsingNotUpsAccountForUpsCrea client := c.ProdClient() assert, require := c.Assert(), c.Require() - createParameters := &easypost.UpsCarrierAccountCreationParameters{ + createParameters := &UpsCarrierAccountCreationParameters{ AccountNumber: "123456789", Type: "NotUpsAccount", } @@ -106,21 +104,21 @@ func (c *ClientTests) TestCarrierAccountPreventUsersUsingNotUpsAccountForUpsCrea _, err := client.CreateUpsCarrierAccount(createParameters) require.Error(err) - assert.Equal(reflect.TypeOf(&easypost.InvalidFunctionError{}), reflect.TypeOf(err)) + assert.Equal(reflect.TypeOf(&InvalidFunctionError{}), reflect.TypeOf(err)) } func (c *ClientTests) TestCarrierAccountCreateOauth() { client := c.ProdClient() assert, require := c.Assert(), c.Require() - createParameters := &easypost.CarrierAccount{ + createParameters := &CarrierAccount{ Type: "AmazonShippingAccount", } carrierAccount, err := client.CreateOauthCarrierAccount(createParameters) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.CarrierAccount{}), reflect.TypeOf(carrierAccount)) + assert.Equal(reflect.TypeOf(&CarrierAccount{}), reflect.TypeOf(carrierAccount)) assert.True(strings.HasPrefix(carrierAccount.ID, "ca_")) assert.Equal("AmazonShippingAccount", carrierAccount.Type) @@ -132,14 +130,14 @@ func (c *ClientTests) TestCarrierAccountPreventUsersUsingNotOauthAccountForOauth client := c.ProdClient() assert, require := c.Assert(), c.Require() - createParameters := &easypost.CarrierAccount{ + createParameters := &CarrierAccount{ Type: "NotOauthAccount", } _, err := client.CreateOauthCarrierAccount(createParameters) require.Error(err) - assert.Equal(reflect.TypeOf(&easypost.InvalidFunctionError{}), reflect.TypeOf(err)) + assert.Equal(reflect.TypeOf(&InvalidFunctionError{}), reflect.TypeOf(err)) } func (c *ClientTests) TestCarrierAccountRetrieve() { @@ -152,7 +150,7 @@ func (c *ClientTests) TestCarrierAccountRetrieve() { retrievedCarrierAccount, err := client.GetCarrierAccount(carrierAccount.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.CarrierAccount{}), reflect.TypeOf(retrievedCarrierAccount)) + assert.Equal(reflect.TypeOf(&CarrierAccount{}), reflect.TypeOf(retrievedCarrierAccount)) assert.Equal(carrierAccount, retrievedCarrierAccount) err = client.DeleteCarrierAccount(carrierAccount.ID) @@ -167,7 +165,7 @@ func (c *ClientTests) TestCarrierAccountAll() { require.NoError(err) for _, carrierAccount := range carrierAccounts { - assert.Equal(reflect.TypeOf(&easypost.CarrierAccount{}), reflect.TypeOf(carrierAccount)) + assert.Equal(reflect.TypeOf(&CarrierAccount{}), reflect.TypeOf(carrierAccount)) } } @@ -180,7 +178,7 @@ func (c *ClientTests) TestCarrierAccountUpdate() { carrierAccount, err := c.GenerateCarrierAccount() require.NoError(err) - updateParameters := &easypost.CarrierAccount{ + updateParameters := &CarrierAccount{ ID: carrierAccount.ID, Description: testDescription, } @@ -188,7 +186,7 @@ func (c *ClientTests) TestCarrierAccountUpdate() { updatedCarrierAccount, err := client.UpdateCarrierAccount(updateParameters) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.CarrierAccount{}), reflect.TypeOf(updatedCarrierAccount)) + assert.Equal(reflect.TypeOf(&CarrierAccount{}), reflect.TypeOf(updatedCarrierAccount)) assert.True(strings.HasPrefix(updatedCarrierAccount.ID, "ca_")) assert.Equal(testDescription, updatedCarrierAccount.Description) @@ -199,13 +197,13 @@ func (c *ClientTests) TestCarrierAccountUpdate() { func (c *ClientTests) TestCarrierAccountPreventUsersUsingUpsAccountForGenericUpdate() { id := "ca_123" - mockRequests := []easypost.MockRequest{ + mockRequests := []MockRequest{ { - MatchRule: easypost.MockRequestMatchRule{ + MatchRule: MockRequestMatchRule{ Method: "GET", UrlRegexPattern: "v2\\/carrier_accounts/" + id + "$", }, - ResponseInfo: easypost.MockRequestResponseInfo{ + ResponseInfo: MockRequestResponseInfo{ StatusCode: 200, Body: `{"id": "` + id + `", "type": "UpsAccount"}`, }, @@ -215,7 +213,7 @@ func (c *ClientTests) TestCarrierAccountPreventUsersUsingUpsAccountForGenericUpd client := c.MockClient(mockRequests) assert, require := c.Assert(), c.Require() - updateParameters := &easypost.CarrierAccount{ + updateParameters := &CarrierAccount{ ID: id, Description: "My custom description", } @@ -223,14 +221,14 @@ func (c *ClientTests) TestCarrierAccountPreventUsersUsingUpsAccountForGenericUpd _, err := client.UpdateCarrierAccount(updateParameters) require.Error(err) - assert.Equal(reflect.TypeOf(&easypost.InvalidFunctionError{}), reflect.TypeOf(err)) + assert.Equal(reflect.TypeOf(&InvalidFunctionError{}), reflect.TypeOf(err)) } func (c *ClientTests) TestCarrierAccountUpdateUps() { client := c.ProdClient() assert, require := c.Assert(), c.Require() - createParameters := &easypost.UpsCarrierAccountCreationParameters{ + createParameters := &UpsCarrierAccountCreationParameters{ AccountNumber: "123456789", Type: "UpsAccount", } @@ -238,14 +236,14 @@ func (c *ClientTests) TestCarrierAccountUpdateUps() { carrierAccount, err := client.CreateUpsCarrierAccount(createParameters) require.NoError(err) - updateParameters := &easypost.UpsCarrierAccountUpdateParameters{ + updateParameters := &UpsCarrierAccountUpdateParameters{ AccountNumber: "987654321", } updatedCarrierAccount, err := client.UpdateUpsCarrierAccount(carrierAccount.ID, updateParameters) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.CarrierAccount{}), reflect.TypeOf(updatedCarrierAccount)) + assert.Equal(reflect.TypeOf(&CarrierAccount{}), reflect.TypeOf(updatedCarrierAccount)) assert.True(strings.HasPrefix(updatedCarrierAccount.ID, "ca_")) err = client.DeleteCarrierAccount(carrierAccount.ID) @@ -255,13 +253,13 @@ func (c *ClientTests) TestCarrierAccountUpdateUps() { func (c *ClientTests) TestCarrierAccountPreventUsersUsingNotUpsAccountForUpsUpdate() { id := "ca_123" - mockRequests := []easypost.MockRequest{ + mockRequests := []MockRequest{ { - MatchRule: easypost.MockRequestMatchRule{ + MatchRule: MockRequestMatchRule{ Method: "GET", UrlRegexPattern: "v2\\/carrier_accounts/" + id + "$", }, - ResponseInfo: easypost.MockRequestResponseInfo{ + ResponseInfo: MockRequestResponseInfo{ StatusCode: 200, Body: `{"id": "` + id + `", "type": "NotUpsAccount"}`, }, @@ -271,14 +269,14 @@ func (c *ClientTests) TestCarrierAccountPreventUsersUsingNotUpsAccountForUpsUpda client := c.MockClient(mockRequests) assert, require := c.Assert(), c.Require() - updateParameters := &easypost.UpsCarrierAccountUpdateParameters{ + updateParameters := &UpsCarrierAccountUpdateParameters{ AccountNumber: "987654321", } _, err := client.UpdateUpsCarrierAccount(id, updateParameters) require.Error(err) - assert.Equal(reflect.TypeOf(&easypost.InvalidFunctionError{}), reflect.TypeOf(err)) + assert.Equal(reflect.TypeOf(&InvalidFunctionError{}), reflect.TypeOf(err)) } func (c *ClientTests) TestCarrierAccountDelete() { @@ -299,5 +297,5 @@ func (c *ClientTests) TestCarrierAccountTypes() { carriersAccountTypes, err := client.GetCarrierTypes() require.NoError(err) - assert.Equal(reflect.TypeOf([]*easypost.CarrierType{}), reflect.TypeOf(carriersAccountTypes)) + assert.Equal(reflect.TypeOf([]*CarrierType{}), reflect.TypeOf(carriersAccountTypes)) } diff --git a/tests/carrier_metadata_test.go b/carrier_metadata_test.go similarity index 98% rename from tests/carrier_metadata_test.go rename to carrier_metadata_test.go index 3a5040b..c4b2dd4 100644 --- a/tests/carrier_metadata_test.go +++ b/carrier_metadata_test.go @@ -1,4 +1,4 @@ -package easypost_test +package easypost func (c *ClientTests) TestGetCarrierMetadata() { client := c.TestClient() diff --git a/tests/cassettes/TestAddReferralCustomerBankAccountFromStripe.yaml b/cassettes/TestAddReferralCustomerBankAccountFromStripe.yaml similarity index 100% rename from tests/cassettes/TestAddReferralCustomerBankAccountFromStripe.yaml rename to cassettes/TestAddReferralCustomerBankAccountFromStripe.yaml diff --git a/tests/cassettes/TestAddReferralCustomerCreditCardFromStripe.yaml b/cassettes/TestAddReferralCustomerCreditCardFromStripe.yaml similarity index 100% rename from tests/cassettes/TestAddReferralCustomerCreditCardFromStripe.yaml rename to cassettes/TestAddReferralCustomerCreditCardFromStripe.yaml diff --git a/tests/cassettes/TestAddressAll.yaml b/cassettes/TestAddressAll.yaml similarity index 100% rename from tests/cassettes/TestAddressAll.yaml rename to cassettes/TestAddressAll.yaml diff --git a/tests/cassettes/TestAddressCreate.yaml b/cassettes/TestAddressCreate.yaml similarity index 100% rename from tests/cassettes/TestAddressCreate.yaml rename to cassettes/TestAddressCreate.yaml diff --git a/tests/cassettes/TestAddressCreateAndVerify.yaml b/cassettes/TestAddressCreateAndVerify.yaml similarity index 100% rename from tests/cassettes/TestAddressCreateAndVerify.yaml rename to cassettes/TestAddressCreateAndVerify.yaml diff --git a/tests/cassettes/TestAddressCreateAndVerifyCarrier.yaml b/cassettes/TestAddressCreateAndVerifyCarrier.yaml similarity index 100% rename from tests/cassettes/TestAddressCreateAndVerifyCarrier.yaml rename to cassettes/TestAddressCreateAndVerifyCarrier.yaml diff --git a/tests/cassettes/TestAddressCreateVerify.yaml b/cassettes/TestAddressCreateVerify.yaml similarity index 100% rename from tests/cassettes/TestAddressCreateVerify.yaml rename to cassettes/TestAddressCreateVerify.yaml diff --git a/tests/cassettes/TestAddressCreateVerifyCarrier.yaml b/cassettes/TestAddressCreateVerifyCarrier.yaml similarity index 100% rename from tests/cassettes/TestAddressCreateVerifyCarrier.yaml rename to cassettes/TestAddressCreateVerifyCarrier.yaml diff --git a/tests/cassettes/TestAddressCreateVerifyStrict.yaml b/cassettes/TestAddressCreateVerifyStrict.yaml similarity index 100% rename from tests/cassettes/TestAddressCreateVerifyStrict.yaml rename to cassettes/TestAddressCreateVerifyStrict.yaml diff --git a/tests/cassettes/TestAddressGetNextPage.yaml b/cassettes/TestAddressGetNextPage.yaml similarity index 100% rename from tests/cassettes/TestAddressGetNextPage.yaml rename to cassettes/TestAddressGetNextPage.yaml diff --git a/tests/cassettes/TestAddressRetrieve.yaml b/cassettes/TestAddressRetrieve.yaml similarity index 100% rename from tests/cassettes/TestAddressRetrieve.yaml rename to cassettes/TestAddressRetrieve.yaml diff --git a/tests/cassettes/TestAddressVerify.yaml b/cassettes/TestAddressVerify.yaml similarity index 100% rename from tests/cassettes/TestAddressVerify.yaml rename to cassettes/TestAddressVerify.yaml diff --git a/tests/cassettes/TestApiError.yaml b/cassettes/TestApiError.yaml similarity index 100% rename from tests/cassettes/TestApiError.yaml rename to cassettes/TestApiError.yaml diff --git a/tests/cassettes/TestApiErrorAlternativeFormat.yaml b/cassettes/TestApiErrorAlternativeFormat.yaml similarity index 100% rename from tests/cassettes/TestApiErrorAlternativeFormat.yaml rename to cassettes/TestApiErrorAlternativeFormat.yaml diff --git a/tests/cassettes/TestApiKeysAll.yaml b/cassettes/TestApiKeysAll.yaml similarity index 100% rename from tests/cassettes/TestApiKeysAll.yaml rename to cassettes/TestApiKeysAll.yaml diff --git a/tests/cassettes/TestApiKeysForChildUser.yaml b/cassettes/TestApiKeysForChildUser.yaml similarity index 100% rename from tests/cassettes/TestApiKeysForChildUser.yaml rename to cassettes/TestApiKeysForChildUser.yaml diff --git a/tests/cassettes/TestApiKeysForParentUser.yaml b/cassettes/TestApiKeysForParentUser.yaml similarity index 100% rename from tests/cassettes/TestApiKeysForParentUser.yaml rename to cassettes/TestApiKeysForParentUser.yaml diff --git a/tests/cassettes/TestBatchAddRemoveShipment.yaml b/cassettes/TestBatchAddRemoveShipment.yaml similarity index 100% rename from tests/cassettes/TestBatchAddRemoveShipment.yaml rename to cassettes/TestBatchAddRemoveShipment.yaml diff --git a/tests/cassettes/TestBatchAll.yaml b/cassettes/TestBatchAll.yaml similarity index 100% rename from tests/cassettes/TestBatchAll.yaml rename to cassettes/TestBatchAll.yaml diff --git a/tests/cassettes/TestBatchBuy.yaml b/cassettes/TestBatchBuy.yaml similarity index 100% rename from tests/cassettes/TestBatchBuy.yaml rename to cassettes/TestBatchBuy.yaml diff --git a/tests/cassettes/TestBatchCreate.yaml b/cassettes/TestBatchCreate.yaml similarity index 100% rename from tests/cassettes/TestBatchCreate.yaml rename to cassettes/TestBatchCreate.yaml diff --git a/tests/cassettes/TestBatchCreateScanForm.yaml b/cassettes/TestBatchCreateScanForm.yaml similarity index 100% rename from tests/cassettes/TestBatchCreateScanForm.yaml rename to cassettes/TestBatchCreateScanForm.yaml diff --git a/tests/cassettes/TestBatchLabel.yaml b/cassettes/TestBatchLabel.yaml similarity index 100% rename from tests/cassettes/TestBatchLabel.yaml rename to cassettes/TestBatchLabel.yaml diff --git a/tests/cassettes/TestBatchRetrieve.yaml b/cassettes/TestBatchRetrieve.yaml similarity index 100% rename from tests/cassettes/TestBatchRetrieve.yaml rename to cassettes/TestBatchRetrieve.yaml diff --git a/tests/cassettes/TestBetaCreateBankAccountClientSecret.yaml b/cassettes/TestBetaCreateBankAccountClientSecret.yaml similarity index 100% rename from tests/cassettes/TestBetaCreateBankAccountClientSecret.yaml rename to cassettes/TestBetaCreateBankAccountClientSecret.yaml diff --git a/tests/cassettes/TestBetaCreateCreditCardClientSecret.yaml b/cassettes/TestBetaCreateCreditCardClientSecret.yaml similarity index 100% rename from tests/cassettes/TestBetaCreateCreditCardClientSecret.yaml rename to cassettes/TestBetaCreateCreditCardClientSecret.yaml diff --git a/tests/cassettes/TestBetaReferralAddPaymentMethod.yaml b/cassettes/TestBetaReferralAddPaymentMethod.yaml similarity index 100% rename from tests/cassettes/TestBetaReferralAddPaymentMethod.yaml rename to cassettes/TestBetaReferralAddPaymentMethod.yaml diff --git a/tests/cassettes/TestBetaReferralRefundByAmount.yaml b/cassettes/TestBetaReferralRefundByAmount.yaml similarity index 100% rename from tests/cassettes/TestBetaReferralRefundByAmount.yaml rename to cassettes/TestBetaReferralRefundByAmount.yaml diff --git a/tests/cassettes/TestBetaReferralRefundByPaymentLogId.yaml b/cassettes/TestBetaReferralRefundByPaymentLogId.yaml similarity index 100% rename from tests/cassettes/TestBetaReferralRefundByPaymentLogId.yaml rename to cassettes/TestBetaReferralRefundByPaymentLogId.yaml diff --git a/tests/cassettes/TestBetaStatelessRateGetLowest.yaml b/cassettes/TestBetaStatelessRateGetLowest.yaml similarity index 100% rename from tests/cassettes/TestBetaStatelessRateGetLowest.yaml rename to cassettes/TestBetaStatelessRateGetLowest.yaml diff --git a/tests/cassettes/TestBetaStatelessRateGetLowestError.yaml b/cassettes/TestBetaStatelessRateGetLowestError.yaml similarity index 100% rename from tests/cassettes/TestBetaStatelessRateGetLowestError.yaml rename to cassettes/TestBetaStatelessRateGetLowestError.yaml diff --git a/tests/cassettes/TestBetaStatelessRateRetrieve.yaml b/cassettes/TestBetaStatelessRateRetrieve.yaml similarity index 100% rename from tests/cassettes/TestBetaStatelessRateRetrieve.yaml rename to cassettes/TestBetaStatelessRateRetrieve.yaml diff --git a/tests/cassettes/TestBuyLumaShipment.yaml b/cassettes/TestBuyLumaShipment.yaml similarity index 100% rename from tests/cassettes/TestBuyLumaShipment.yaml rename to cassettes/TestBuyLumaShipment.yaml diff --git a/tests/cassettes/TestBuyShipmentWithEndShipper.yaml b/cassettes/TestBuyShipmentWithEndShipper.yaml similarity index 100% rename from tests/cassettes/TestBuyShipmentWithEndShipper.yaml rename to cassettes/TestBuyShipmentWithEndShipper.yaml diff --git a/tests/cassettes/TestCarrierAccountAll.yaml b/cassettes/TestCarrierAccountAll.yaml similarity index 100% rename from tests/cassettes/TestCarrierAccountAll.yaml rename to cassettes/TestCarrierAccountAll.yaml diff --git a/tests/cassettes/TestCarrierAccountCreate.yaml b/cassettes/TestCarrierAccountCreate.yaml similarity index 100% rename from tests/cassettes/TestCarrierAccountCreate.yaml rename to cassettes/TestCarrierAccountCreate.yaml diff --git a/tests/cassettes/TestCarrierAccountCreateOauth.yaml b/cassettes/TestCarrierAccountCreateOauth.yaml similarity index 100% rename from tests/cassettes/TestCarrierAccountCreateOauth.yaml rename to cassettes/TestCarrierAccountCreateOauth.yaml diff --git a/tests/cassettes/TestCarrierAccountCreateUps.yaml b/cassettes/TestCarrierAccountCreateUps.yaml similarity index 100% rename from tests/cassettes/TestCarrierAccountCreateUps.yaml rename to cassettes/TestCarrierAccountCreateUps.yaml diff --git a/tests/cassettes/TestCarrierAccountCreateWithCustomWorkflow.yaml b/cassettes/TestCarrierAccountCreateWithCustomWorkflow.yaml similarity index 100% rename from tests/cassettes/TestCarrierAccountCreateWithCustomWorkflow.yaml rename to cassettes/TestCarrierAccountCreateWithCustomWorkflow.yaml diff --git a/tests/cassettes/TestCarrierAccountDelete.yaml b/cassettes/TestCarrierAccountDelete.yaml similarity index 100% rename from tests/cassettes/TestCarrierAccountDelete.yaml rename to cassettes/TestCarrierAccountDelete.yaml diff --git a/tests/cassettes/TestCarrierAccountRetrieve.yaml b/cassettes/TestCarrierAccountRetrieve.yaml similarity index 100% rename from tests/cassettes/TestCarrierAccountRetrieve.yaml rename to cassettes/TestCarrierAccountRetrieve.yaml diff --git a/tests/cassettes/TestCarrierAccountTypes.yaml b/cassettes/TestCarrierAccountTypes.yaml similarity index 100% rename from tests/cassettes/TestCarrierAccountTypes.yaml rename to cassettes/TestCarrierAccountTypes.yaml diff --git a/tests/cassettes/TestCarrierAccountUpdate.yaml b/cassettes/TestCarrierAccountUpdate.yaml similarity index 100% rename from tests/cassettes/TestCarrierAccountUpdate.yaml rename to cassettes/TestCarrierAccountUpdate.yaml diff --git a/tests/cassettes/TestCarrierAccountUpdateUps.yaml b/cassettes/TestCarrierAccountUpdateUps.yaml similarity index 100% rename from tests/cassettes/TestCarrierAccountUpdateUps.yaml rename to cassettes/TestCarrierAccountUpdateUps.yaml diff --git a/tests/cassettes/TestClaimAll.yaml b/cassettes/TestClaimAll.yaml similarity index 100% rename from tests/cassettes/TestClaimAll.yaml rename to cassettes/TestClaimAll.yaml diff --git a/tests/cassettes/TestClaimCancel.yaml b/cassettes/TestClaimCancel.yaml similarity index 100% rename from tests/cassettes/TestClaimCancel.yaml rename to cassettes/TestClaimCancel.yaml diff --git a/tests/cassettes/TestClaimCreate.yaml b/cassettes/TestClaimCreate.yaml similarity index 100% rename from tests/cassettes/TestClaimCreate.yaml rename to cassettes/TestClaimCreate.yaml diff --git a/tests/cassettes/TestClaimGetNextPage.yaml b/cassettes/TestClaimGetNextPage.yaml similarity index 100% rename from tests/cassettes/TestClaimGetNextPage.yaml rename to cassettes/TestClaimGetNextPage.yaml diff --git a/tests/cassettes/TestClaimRetrieve.yaml b/cassettes/TestClaimRetrieve.yaml similarity index 100% rename from tests/cassettes/TestClaimRetrieve.yaml rename to cassettes/TestClaimRetrieve.yaml diff --git a/tests/cassettes/TestCreateAndBuyLumaShipment.yaml b/cassettes/TestCreateAndBuyLumaShipment.yaml similarity index 100% rename from tests/cassettes/TestCreateAndBuyLumaShipment.yaml rename to cassettes/TestCreateAndBuyLumaShipment.yaml diff --git a/tests/cassettes/TestCustomsInfoCreate.yaml b/cassettes/TestCustomsInfoCreate.yaml similarity index 100% rename from tests/cassettes/TestCustomsInfoCreate.yaml rename to cassettes/TestCustomsInfoCreate.yaml diff --git a/tests/cassettes/TestCustomsInfoRetrieve.yaml b/cassettes/TestCustomsInfoRetrieve.yaml similarity index 100% rename from tests/cassettes/TestCustomsInfoRetrieve.yaml rename to cassettes/TestCustomsInfoRetrieve.yaml diff --git a/tests/cassettes/TestCustomsItemCreate.yaml b/cassettes/TestCustomsItemCreate.yaml similarity index 100% rename from tests/cassettes/TestCustomsItemCreate.yaml rename to cassettes/TestCustomsItemCreate.yaml diff --git a/tests/cassettes/TestCustomsItemRetrieve.yaml b/cassettes/TestCustomsItemRetrieve.yaml similarity index 100% rename from tests/cassettes/TestCustomsItemRetrieve.yaml rename to cassettes/TestCustomsItemRetrieve.yaml diff --git a/tests/cassettes/TestDateTimeJSON.yaml b/cassettes/TestDateTimeJSON.yaml similarity index 100% rename from tests/cassettes/TestDateTimeJSON.yaml rename to cassettes/TestDateTimeJSON.yaml diff --git a/tests/cassettes/TestEndShipperAll.yaml b/cassettes/TestEndShipperAll.yaml similarity index 100% rename from tests/cassettes/TestEndShipperAll.yaml rename to cassettes/TestEndShipperAll.yaml diff --git a/tests/cassettes/TestEndShipperCreate.yaml b/cassettes/TestEndShipperCreate.yaml similarity index 100% rename from tests/cassettes/TestEndShipperCreate.yaml rename to cassettes/TestEndShipperCreate.yaml diff --git a/tests/cassettes/TestEndShipperRetrieve.yaml b/cassettes/TestEndShipperRetrieve.yaml similarity index 100% rename from tests/cassettes/TestEndShipperRetrieve.yaml rename to cassettes/TestEndShipperRetrieve.yaml diff --git a/tests/cassettes/TestEndShipperUpdate.yaml b/cassettes/TestEndShipperUpdate.yaml similarity index 100% rename from tests/cassettes/TestEndShipperUpdate.yaml rename to cassettes/TestEndShipperUpdate.yaml diff --git a/tests/cassettes/TestErrorInheritance.yaml b/cassettes/TestErrorInheritance.yaml similarity index 100% rename from tests/cassettes/TestErrorInheritance.yaml rename to cassettes/TestErrorInheritance.yaml diff --git a/tests/cassettes/TestEstimateDeliveryDateForZipPair.yaml b/cassettes/TestEstimateDeliveryDateForZipPair.yaml similarity index 100% rename from tests/cassettes/TestEstimateDeliveryDateForZipPair.yaml rename to cassettes/TestEstimateDeliveryDateForZipPair.yaml diff --git a/tests/cassettes/TestEventAll.yaml b/cassettes/TestEventAll.yaml similarity index 100% rename from tests/cassettes/TestEventAll.yaml rename to cassettes/TestEventAll.yaml diff --git a/tests/cassettes/TestEventRetrieve.yaml b/cassettes/TestEventRetrieve.yaml similarity index 100% rename from tests/cassettes/TestEventRetrieve.yaml rename to cassettes/TestEventRetrieve.yaml diff --git a/tests/cassettes/TestEventRetrieveAllPayloads.yaml b/cassettes/TestEventRetrieveAllPayloads.yaml similarity index 100% rename from tests/cassettes/TestEventRetrieveAllPayloads.yaml rename to cassettes/TestEventRetrieveAllPayloads.yaml diff --git a/tests/cassettes/TestEventRetrievePayload.yaml b/cassettes/TestEventRetrievePayload.yaml similarity index 100% rename from tests/cassettes/TestEventRetrievePayload.yaml rename to cassettes/TestEventRetrievePayload.yaml diff --git a/tests/cassettes/TestEventsGetNextPage.yaml b/cassettes/TestEventsGetNextPage.yaml similarity index 100% rename from tests/cassettes/TestEventsGetNextPage.yaml rename to cassettes/TestEventsGetNextPage.yaml diff --git a/tests/cassettes/TestGetCarrierMetadata.yaml b/cassettes/TestGetCarrierMetadata.yaml similarity index 100% rename from tests/cassettes/TestGetCarrierMetadata.yaml rename to cassettes/TestGetCarrierMetadata.yaml diff --git a/tests/cassettes/TestGetCarrierMetadataWithCarriersAndTypes.yaml b/cassettes/TestGetCarrierMetadataWithCarriersAndTypes.yaml similarity index 100% rename from tests/cassettes/TestGetCarrierMetadataWithCarriersAndTypes.yaml rename to cassettes/TestGetCarrierMetadataWithCarriersAndTypes.yaml diff --git a/tests/cassettes/TestGetLumaPromise.yaml b/cassettes/TestGetLumaPromise.yaml similarity index 100% rename from tests/cassettes/TestGetLumaPromise.yaml rename to cassettes/TestGetLumaPromise.yaml diff --git a/tests/cassettes/TestGetNextPage.yaml b/cassettes/TestGetNextPage.yaml similarity index 100% rename from tests/cassettes/TestGetNextPage.yaml rename to cassettes/TestGetNextPage.yaml diff --git a/tests/cassettes/TestGetNextPageWithPageSize.yaml b/cassettes/TestGetNextPageWithPageSize.yaml similarity index 100% rename from tests/cassettes/TestGetNextPageWithPageSize.yaml rename to cassettes/TestGetNextPageWithPageSize.yaml diff --git a/tests/cassettes/TestHooks.yaml b/cassettes/TestHooks.yaml similarity index 100% rename from tests/cassettes/TestHooks.yaml rename to cassettes/TestHooks.yaml diff --git a/tests/cassettes/TestHooksUnsubscribing.yaml b/cassettes/TestHooksUnsubscribing.yaml similarity index 100% rename from tests/cassettes/TestHooksUnsubscribing.yaml rename to cassettes/TestHooksUnsubscribing.yaml diff --git a/tests/cassettes/TestInsuranceAll.yaml b/cassettes/TestInsuranceAll.yaml similarity index 100% rename from tests/cassettes/TestInsuranceAll.yaml rename to cassettes/TestInsuranceAll.yaml diff --git a/tests/cassettes/TestInsuranceCreate.yaml b/cassettes/TestInsuranceCreate.yaml similarity index 100% rename from tests/cassettes/TestInsuranceCreate.yaml rename to cassettes/TestInsuranceCreate.yaml diff --git a/tests/cassettes/TestInsuranceGetNextPage.yaml b/cassettes/TestInsuranceGetNextPage.yaml similarity index 100% rename from tests/cassettes/TestInsuranceGetNextPage.yaml rename to cassettes/TestInsuranceGetNextPage.yaml diff --git a/tests/cassettes/TestInsuranceRefund.yaml b/cassettes/TestInsuranceRefund.yaml similarity index 100% rename from tests/cassettes/TestInsuranceRefund.yaml rename to cassettes/TestInsuranceRefund.yaml diff --git a/tests/cassettes/TestInsuranceRetrieve.yaml b/cassettes/TestInsuranceRetrieve.yaml similarity index 100% rename from tests/cassettes/TestInsuranceRetrieve.yaml rename to cassettes/TestInsuranceRetrieve.yaml diff --git a/tests/cassettes/TestMultipleHooks.yaml b/cassettes/TestMultipleHooks.yaml similarity index 100% rename from tests/cassettes/TestMultipleHooks.yaml rename to cassettes/TestMultipleHooks.yaml diff --git a/tests/cassettes/TestOrderBuyRate.yaml b/cassettes/TestOrderBuyRate.yaml similarity index 100% rename from tests/cassettes/TestOrderBuyRate.yaml rename to cassettes/TestOrderBuyRate.yaml diff --git a/tests/cassettes/TestOrderCreate.yaml b/cassettes/TestOrderCreate.yaml similarity index 100% rename from tests/cassettes/TestOrderCreate.yaml rename to cassettes/TestOrderCreate.yaml diff --git a/tests/cassettes/TestOrderGetRates.yaml b/cassettes/TestOrderGetRates.yaml similarity index 100% rename from tests/cassettes/TestOrderGetRates.yaml rename to cassettes/TestOrderGetRates.yaml diff --git a/tests/cassettes/TestOrderLowestRate.yaml b/cassettes/TestOrderLowestRate.yaml similarity index 100% rename from tests/cassettes/TestOrderLowestRate.yaml rename to cassettes/TestOrderLowestRate.yaml diff --git a/tests/cassettes/TestOrderRetrieve.yaml b/cassettes/TestOrderRetrieve.yaml similarity index 100% rename from tests/cassettes/TestOrderRetrieve.yaml rename to cassettes/TestOrderRetrieve.yaml diff --git a/tests/cassettes/TestParcelCreate.yaml b/cassettes/TestParcelCreate.yaml similarity index 100% rename from tests/cassettes/TestParcelCreate.yaml rename to cassettes/TestParcelCreate.yaml diff --git a/tests/cassettes/TestParcelRetrieve.yaml b/cassettes/TestParcelRetrieve.yaml similarity index 100% rename from tests/cassettes/TestParcelRetrieve.yaml rename to cassettes/TestParcelRetrieve.yaml diff --git a/tests/cassettes/TestPickupAll.yaml b/cassettes/TestPickupAll.yaml similarity index 100% rename from tests/cassettes/TestPickupAll.yaml rename to cassettes/TestPickupAll.yaml diff --git a/tests/cassettes/TestPickupBuy.yaml b/cassettes/TestPickupBuy.yaml similarity index 100% rename from tests/cassettes/TestPickupBuy.yaml rename to cassettes/TestPickupBuy.yaml diff --git a/tests/cassettes/TestPickupCancel.yaml b/cassettes/TestPickupCancel.yaml similarity index 100% rename from tests/cassettes/TestPickupCancel.yaml rename to cassettes/TestPickupCancel.yaml diff --git a/tests/cassettes/TestPickupCreate.yaml b/cassettes/TestPickupCreate.yaml similarity index 100% rename from tests/cassettes/TestPickupCreate.yaml rename to cassettes/TestPickupCreate.yaml diff --git a/tests/cassettes/TestPickupLowestRate.yaml b/cassettes/TestPickupLowestRate.yaml similarity index 100% rename from tests/cassettes/TestPickupLowestRate.yaml rename to cassettes/TestPickupLowestRate.yaml diff --git a/tests/cassettes/TestPickupRetrieve.yaml b/cassettes/TestPickupRetrieve.yaml similarity index 100% rename from tests/cassettes/TestPickupRetrieve.yaml rename to cassettes/TestPickupRetrieve.yaml diff --git a/tests/cassettes/TestPickupsGetNextPage.yaml b/cassettes/TestPickupsGetNextPage.yaml similarity index 100% rename from tests/cassettes/TestPickupsGetNextPage.yaml rename to cassettes/TestPickupsGetNextPage.yaml diff --git a/tests/cassettes/TestRateRetrieve.yaml b/cassettes/TestRateRetrieve.yaml similarity index 100% rename from tests/cassettes/TestRateRetrieve.yaml rename to cassettes/TestRateRetrieve.yaml diff --git a/tests/cassettes/TestRecommendShipDateForZipPair.yaml b/cassettes/TestRecommendShipDateForZipPair.yaml similarity index 100% rename from tests/cassettes/TestRecommendShipDateForZipPair.yaml rename to cassettes/TestRecommendShipDateForZipPair.yaml diff --git a/tests/cassettes/TestReferralCustomerAddCreditCard.yaml b/cassettes/TestReferralCustomerAddCreditCard.yaml similarity index 100% rename from tests/cassettes/TestReferralCustomerAddCreditCard.yaml rename to cassettes/TestReferralCustomerAddCreditCard.yaml diff --git a/tests/cassettes/TestReferralCustomerAll.yaml b/cassettes/TestReferralCustomerAll.yaml similarity index 100% rename from tests/cassettes/TestReferralCustomerAll.yaml rename to cassettes/TestReferralCustomerAll.yaml diff --git a/tests/cassettes/TestReferralCustomerCreate.yaml b/cassettes/TestReferralCustomerCreate.yaml similarity index 100% rename from tests/cassettes/TestReferralCustomerCreate.yaml rename to cassettes/TestReferralCustomerCreate.yaml diff --git a/tests/cassettes/TestReferralCustomerUpdate.yaml b/cassettes/TestReferralCustomerUpdate.yaml similarity index 100% rename from tests/cassettes/TestReferralCustomerUpdate.yaml rename to cassettes/TestReferralCustomerUpdate.yaml diff --git a/tests/cassettes/TestReferralCustomersGetNextPage.yaml b/cassettes/TestReferralCustomersGetNextPage.yaml similarity index 100% rename from tests/cassettes/TestReferralCustomersGetNextPage.yaml rename to cassettes/TestReferralCustomersGetNextPage.yaml diff --git a/tests/cassettes/TestRefundAll.yaml b/cassettes/TestRefundAll.yaml similarity index 100% rename from tests/cassettes/TestRefundAll.yaml rename to cassettes/TestRefundAll.yaml diff --git a/tests/cassettes/TestRefundCreate.yaml b/cassettes/TestRefundCreate.yaml similarity index 100% rename from tests/cassettes/TestRefundCreate.yaml rename to cassettes/TestRefundCreate.yaml diff --git a/tests/cassettes/TestRefundRetrieve.yaml b/cassettes/TestRefundRetrieve.yaml similarity index 100% rename from tests/cassettes/TestRefundRetrieve.yaml rename to cassettes/TestRefundRetrieve.yaml diff --git a/tests/cassettes/TestRefundsGetNextPage.yaml b/cassettes/TestRefundsGetNextPage.yaml similarity index 100% rename from tests/cassettes/TestRefundsGetNextPage.yaml rename to cassettes/TestRefundsGetNextPage.yaml diff --git a/tests/cassettes/TestReportAll.yaml b/cassettes/TestReportAll.yaml similarity index 100% rename from tests/cassettes/TestReportAll.yaml rename to cassettes/TestReportAll.yaml diff --git a/tests/cassettes/TestReportCreate.yaml b/cassettes/TestReportCreate.yaml similarity index 100% rename from tests/cassettes/TestReportCreate.yaml rename to cassettes/TestReportCreate.yaml diff --git a/tests/cassettes/TestReportCustomAdditionalColumnsCreate.yaml b/cassettes/TestReportCustomAdditionalColumnsCreate.yaml similarity index 100% rename from tests/cassettes/TestReportCustomAdditionalColumnsCreate.yaml rename to cassettes/TestReportCustomAdditionalColumnsCreate.yaml diff --git a/tests/cassettes/TestReportCustomColumnsCreate.yaml b/cassettes/TestReportCustomColumnsCreate.yaml similarity index 100% rename from tests/cassettes/TestReportCustomColumnsCreate.yaml rename to cassettes/TestReportCustomColumnsCreate.yaml diff --git a/tests/cassettes/TestReportRetrieve.yaml b/cassettes/TestReportRetrieve.yaml similarity index 100% rename from tests/cassettes/TestReportRetrieve.yaml rename to cassettes/TestReportRetrieve.yaml diff --git a/tests/cassettes/TestReportsGetNextPage.yaml b/cassettes/TestReportsGetNextPage.yaml similarity index 100% rename from tests/cassettes/TestReportsGetNextPage.yaml rename to cassettes/TestReportsGetNextPage.yaml diff --git a/tests/cassettes/TestScanFormAll.yaml b/cassettes/TestScanFormAll.yaml similarity index 100% rename from tests/cassettes/TestScanFormAll.yaml rename to cassettes/TestScanFormAll.yaml diff --git a/tests/cassettes/TestScanFormCreate.yaml b/cassettes/TestScanFormCreate.yaml similarity index 100% rename from tests/cassettes/TestScanFormCreate.yaml rename to cassettes/TestScanFormCreate.yaml diff --git a/tests/cassettes/TestScanFormRetrieve.yaml b/cassettes/TestScanFormRetrieve.yaml similarity index 100% rename from tests/cassettes/TestScanFormRetrieve.yaml rename to cassettes/TestScanFormRetrieve.yaml diff --git a/tests/cassettes/TestScanFormsGetNextPage.yaml b/cassettes/TestScanFormsGetNextPage.yaml similarity index 100% rename from tests/cassettes/TestScanFormsGetNextPage.yaml rename to cassettes/TestScanFormsGetNextPage.yaml diff --git a/tests/cassettes/TestShipmentAll.yaml b/cassettes/TestShipmentAll.yaml similarity index 100% rename from tests/cassettes/TestShipmentAll.yaml rename to cassettes/TestShipmentAll.yaml diff --git a/tests/cassettes/TestShipmentBuy.yaml b/cassettes/TestShipmentBuy.yaml similarity index 100% rename from tests/cassettes/TestShipmentBuy.yaml rename to cassettes/TestShipmentBuy.yaml diff --git a/tests/cassettes/TestShipmentConvertLabel.yaml b/cassettes/TestShipmentConvertLabel.yaml similarity index 100% rename from tests/cassettes/TestShipmentConvertLabel.yaml rename to cassettes/TestShipmentConvertLabel.yaml diff --git a/tests/cassettes/TestShipmentCreate.yaml b/cassettes/TestShipmentCreate.yaml similarity index 100% rename from tests/cassettes/TestShipmentCreate.yaml rename to cassettes/TestShipmentCreate.yaml diff --git a/tests/cassettes/TestShipmentCreateEmptyObjects.yaml b/cassettes/TestShipmentCreateEmptyObjects.yaml similarity index 100% rename from tests/cassettes/TestShipmentCreateEmptyObjects.yaml rename to cassettes/TestShipmentCreateEmptyObjects.yaml diff --git a/tests/cassettes/TestShipmentCreateTaxIdentifier.yaml b/cassettes/TestShipmentCreateTaxIdentifier.yaml similarity index 100% rename from tests/cassettes/TestShipmentCreateTaxIdentifier.yaml rename to cassettes/TestShipmentCreateTaxIdentifier.yaml diff --git a/tests/cassettes/TestShipmentCreateWithIds.yaml b/cassettes/TestShipmentCreateWithIds.yaml similarity index 100% rename from tests/cassettes/TestShipmentCreateWithIds.yaml rename to cassettes/TestShipmentCreateWithIds.yaml diff --git a/tests/cassettes/TestShipmentGenerateForm.yaml b/cassettes/TestShipmentGenerateForm.yaml similarity index 100% rename from tests/cassettes/TestShipmentGenerateForm.yaml rename to cassettes/TestShipmentGenerateForm.yaml diff --git a/tests/cassettes/TestShipmentGetShipmentEstimatedDeliveryDate.yaml b/cassettes/TestShipmentGetShipmentEstimatedDeliveryDate.yaml similarity index 100% rename from tests/cassettes/TestShipmentGetShipmentEstimatedDeliveryDate.yaml rename to cassettes/TestShipmentGetShipmentEstimatedDeliveryDate.yaml diff --git a/tests/cassettes/TestShipmentInstanceLowestSmartRate.yaml b/cassettes/TestShipmentInstanceLowestSmartRate.yaml similarity index 100% rename from tests/cassettes/TestShipmentInstanceLowestSmartRate.yaml rename to cassettes/TestShipmentInstanceLowestSmartRate.yaml diff --git a/tests/cassettes/TestShipmentInsure.yaml b/cassettes/TestShipmentInsure.yaml similarity index 100% rename from tests/cassettes/TestShipmentInsure.yaml rename to cassettes/TestShipmentInsure.yaml diff --git a/tests/cassettes/TestShipmentLowestRate.yaml b/cassettes/TestShipmentLowestRate.yaml similarity index 100% rename from tests/cassettes/TestShipmentLowestRate.yaml rename to cassettes/TestShipmentLowestRate.yaml diff --git a/tests/cassettes/TestShipmentRecommendShipDate.yaml b/cassettes/TestShipmentRecommendShipDate.yaml similarity index 100% rename from tests/cassettes/TestShipmentRecommendShipDate.yaml rename to cassettes/TestShipmentRecommendShipDate.yaml diff --git a/tests/cassettes/TestShipmentRefund.yaml b/cassettes/TestShipmentRefund.yaml similarity index 100% rename from tests/cassettes/TestShipmentRefund.yaml rename to cassettes/TestShipmentRefund.yaml diff --git a/tests/cassettes/TestShipmentRegenerateRates.yaml b/cassettes/TestShipmentRegenerateRates.yaml similarity index 100% rename from tests/cassettes/TestShipmentRegenerateRates.yaml rename to cassettes/TestShipmentRegenerateRates.yaml diff --git a/tests/cassettes/TestShipmentRetrieve.yaml b/cassettes/TestShipmentRetrieve.yaml similarity index 100% rename from tests/cassettes/TestShipmentRetrieve.yaml rename to cassettes/TestShipmentRetrieve.yaml diff --git a/tests/cassettes/TestShipmentSmartrate.yaml b/cassettes/TestShipmentSmartrate.yaml similarity index 100% rename from tests/cassettes/TestShipmentSmartrate.yaml rename to cassettes/TestShipmentSmartrate.yaml diff --git a/tests/cassettes/TestShipmentsGetNextPage.yaml b/cassettes/TestShipmentsGetNextPage.yaml similarity index 100% rename from tests/cassettes/TestShipmentsGetNextPage.yaml rename to cassettes/TestShipmentsGetNextPage.yaml diff --git a/tests/cassettes/TestTrackerAll.yaml b/cassettes/TestTrackerAll.yaml similarity index 100% rename from tests/cassettes/TestTrackerAll.yaml rename to cassettes/TestTrackerAll.yaml diff --git a/tests/cassettes/TestTrackerCreate.yaml b/cassettes/TestTrackerCreate.yaml similarity index 100% rename from tests/cassettes/TestTrackerCreate.yaml rename to cassettes/TestTrackerCreate.yaml diff --git a/tests/cassettes/TestTrackerRetrieve.yaml b/cassettes/TestTrackerRetrieve.yaml similarity index 100% rename from tests/cassettes/TestTrackerRetrieve.yaml rename to cassettes/TestTrackerRetrieve.yaml diff --git a/tests/cassettes/TestTrackerRetrieveBatch.yaml b/cassettes/TestTrackerRetrieveBatch.yaml similarity index 100% rename from tests/cassettes/TestTrackerRetrieveBatch.yaml rename to cassettes/TestTrackerRetrieveBatch.yaml diff --git a/tests/cassettes/TestTrackersGetNextPage.yaml b/cassettes/TestTrackersGetNextPage.yaml similarity index 100% rename from tests/cassettes/TestTrackersGetNextPage.yaml rename to cassettes/TestTrackersGetNextPage.yaml diff --git a/tests/cassettes/TestUserAllChildUsers.yaml b/cassettes/TestUserAllChildUsers.yaml similarity index 100% rename from tests/cassettes/TestUserAllChildUsers.yaml rename to cassettes/TestUserAllChildUsers.yaml diff --git a/tests/cassettes/TestUserCreate.yaml b/cassettes/TestUserCreate.yaml similarity index 100% rename from tests/cassettes/TestUserCreate.yaml rename to cassettes/TestUserCreate.yaml diff --git a/tests/cassettes/TestUserDelete.yaml b/cassettes/TestUserDelete.yaml similarity index 100% rename from tests/cassettes/TestUserDelete.yaml rename to cassettes/TestUserDelete.yaml diff --git a/tests/cassettes/TestUserGetNextChildUserPage.yaml b/cassettes/TestUserGetNextChildUserPage.yaml similarity index 100% rename from tests/cassettes/TestUserGetNextChildUserPage.yaml rename to cassettes/TestUserGetNextChildUserPage.yaml diff --git a/tests/cassettes/TestUserRetrieve.yaml b/cassettes/TestUserRetrieve.yaml similarity index 100% rename from tests/cassettes/TestUserRetrieve.yaml rename to cassettes/TestUserRetrieve.yaml diff --git a/tests/cassettes/TestUserRetrieveMe.yaml b/cassettes/TestUserRetrieveMe.yaml similarity index 100% rename from tests/cassettes/TestUserRetrieveMe.yaml rename to cassettes/TestUserRetrieveMe.yaml diff --git a/tests/cassettes/TestUserUpdate.yaml b/cassettes/TestUserUpdate.yaml similarity index 100% rename from tests/cassettes/TestUserUpdate.yaml rename to cassettes/TestUserUpdate.yaml diff --git a/tests/cassettes/TestUserUpdateBrand.yaml b/cassettes/TestUserUpdateBrand.yaml similarity index 100% rename from tests/cassettes/TestUserUpdateBrand.yaml rename to cassettes/TestUserUpdateBrand.yaml diff --git a/tests/cassettes/TestWebhookAll.yaml b/cassettes/TestWebhookAll.yaml similarity index 100% rename from tests/cassettes/TestWebhookAll.yaml rename to cassettes/TestWebhookAll.yaml diff --git a/tests/cassettes/TestWebhookCreate.yaml b/cassettes/TestWebhookCreate.yaml similarity index 100% rename from tests/cassettes/TestWebhookCreate.yaml rename to cassettes/TestWebhookCreate.yaml diff --git a/tests/cassettes/TestWebhookCreateWithSecret.yaml b/cassettes/TestWebhookCreateWithSecret.yaml similarity index 100% rename from tests/cassettes/TestWebhookCreateWithSecret.yaml rename to cassettes/TestWebhookCreateWithSecret.yaml diff --git a/tests/cassettes/TestWebhookDelete.yaml b/cassettes/TestWebhookDelete.yaml similarity index 100% rename from tests/cassettes/TestWebhookDelete.yaml rename to cassettes/TestWebhookDelete.yaml diff --git a/tests/cassettes/TestWebhookRetrieve.yaml b/cassettes/TestWebhookRetrieve.yaml similarity index 100% rename from tests/cassettes/TestWebhookRetrieve.yaml rename to cassettes/TestWebhookRetrieve.yaml diff --git a/tests/cassettes/TestWebhookUpdate.yaml b/cassettes/TestWebhookUpdate.yaml similarity index 100% rename from tests/cassettes/TestWebhookUpdate.yaml rename to cassettes/TestWebhookUpdate.yaml diff --git a/tests/cassettes/TestWebhookUpdateWithSecret.yaml b/cassettes/TestWebhookUpdateWithSecret.yaml similarity index 100% rename from tests/cassettes/TestWebhookUpdateWithSecret.yaml rename to cassettes/TestWebhookUpdateWithSecret.yaml diff --git a/tests/claim_test.go b/claim_test.go similarity index 84% rename from tests/claim_test.go rename to claim_test.go index e3bb5dd..d600f1e 100644 --- a/tests/claim_test.go +++ b/claim_test.go @@ -1,15 +1,13 @@ -package easypost_test +package easypost import ( "errors" "reflect" "strconv" "strings" - - "github.com/EasyPost/easypost-go/v5" ) -func prepareInsuredShipment(client *easypost.Client, shipmentCreateParams *easypost.Shipment, claimAmount float64) *easypost.Shipment { +func prepareInsuredShipment(client *Client, shipmentCreateParams *Shipment, claimAmount float64) *Shipment { shipment, err := client.CreateShipment(shipmentCreateParams) if err != nil { panic(err) @@ -44,7 +42,7 @@ func (c *ClientTests) TestClaimCreate() { claim, err := client.CreateClaim(createClaimParams) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Claim{}), reflect.TypeOf(claim)) + assert.Equal(reflect.TypeOf(&Claim{}), reflect.TypeOf(claim)) assert.True(strings.HasPrefix(claim.ID, "clm_")) assert.Equal(createClaimParams.TrackingCode, claim.TrackingCode) assert.Equal(claimAmountStr, claim.RequestedAmount) @@ -69,7 +67,7 @@ func (c *ClientTests) TestClaimRetrieve() { retrievedClaim, err := client.GetClaim(claim.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Claim{}), reflect.TypeOf(retrievedClaim)) + assert.Equal(reflect.TypeOf(&Claim{}), reflect.TypeOf(retrievedClaim)) assert.Equal(claim.ID, retrievedClaim.ID) } @@ -77,7 +75,7 @@ func (c *ClientTests) TestClaimAll() { client := c.TestClient() assert, require := c.Assert(), c.Require() - listClaimsParams := &easypost.ListClaimsParameters{ + listClaimsParams := &ListClaimsParameters{ PageSize: c.fixture.pageSize(), } @@ -89,7 +87,7 @@ func (c *ClientTests) TestClaimAll() { assert.LessOrEqual(len(claimsList), c.fixture.pageSize()) assert.NotNil(claims.HasMore) for _, claim := range claimsList { - assert.Equal(reflect.TypeOf(&easypost.Claim{}), reflect.TypeOf(claim)) + assert.Equal(reflect.TypeOf(&Claim{}), reflect.TypeOf(claim)) } } @@ -97,7 +95,7 @@ func (c *ClientTests) TestClaimGetNextPage() { client := c.TestClient() assert, require := c.Assert(), c.Require() - listClaimsParams := &easypost.ListClaimsParameters{ + listClaimsParams := &ListClaimsParameters{ PageSize: c.fixture.pageSize(), } @@ -116,7 +114,7 @@ func (c *ClientTests) TestClaimGetNextPage() { } }() if err != nil { - var endOfPaginationErr *easypost.EndOfPaginationError + var endOfPaginationErr *EndOfPaginationError if errors.As(err, &endOfPaginationErr) { assert.Equal(err.Error(), endOfPaginationErr.Error()) return @@ -144,7 +142,7 @@ func (c *ClientTests) TestClaimCancel() { cancelledClaim, err := client.CancelClaim(claim.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Claim{}), reflect.TypeOf(cancelledClaim)) + assert.Equal(reflect.TypeOf(&Claim{}), reflect.TypeOf(cancelledClaim)) assert.True(strings.HasPrefix(cancelledClaim.ID, "clm_")) assert.Equal("cancelled", cancelledClaim.Status) } diff --git a/tests/client_test.go b/client_test.go similarity index 71% rename from tests/client_test.go rename to client_test.go index 7c05478..174dae5 100644 --- a/tests/client_test.go +++ b/client_test.go @@ -1,18 +1,18 @@ -package easypost_test +package easypost import ( "context" - "github.com/EasyPost/easypost-go/v5" + "github.com/google/uuid" ) func (c *ClientTests) TestCreateClient() { require := c.Require() - client := easypost.New("") + client := New("") _, err := client.ListAddresses( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -30,28 +30,28 @@ func (c *ClientTests) TestHooks() { var pairId uuid.UUID client.Hooks.AddRequestEventSubscriber( - easypost.RequestHookEventSubscriber{ - Callback: func(ctx context.Context, event easypost.RequestHookEvent) error { + RequestHookEventSubscriber{ + Callback: func(ctx context.Context, event RequestHookEvent) error { assert.Equal("GET", event.Method) - assert.Regexp("^https://api.easypost.com/v2/addresses", event.Url.String()) + assert.Equal("https://api.easypost.com/v2/addresses?page_size=5", event.Url.String()) pairId = event.Id requestHookCalled = true return nil }, - HookEventSubscriber: easypost.HookEventSubscriber{ + HookEventSubscriber: HookEventSubscriber{ ID: "hook_1", }, }) client.Hooks.AddResponseEventSubscriber( - easypost.ResponseHookEventSubscriber{ - Callback: func(ctx context.Context, event easypost.ResponseHookEvent) error { + ResponseHookEventSubscriber{ + Callback: func(ctx context.Context, event ResponseHookEvent) error { assert.Equal(200, event.HttpStatus) assert.Equal("GET", event.Method) assert.Equal(pairId, event.Id) responseHookCalled = true return nil }, - HookEventSubscriber: easypost.HookEventSubscriber{ + HookEventSubscriber: HookEventSubscriber{ ID: "hook_2", }, }) @@ -62,7 +62,7 @@ func (c *ClientTests) TestHooks() { // fire off a request _, err := client.ListAddresses( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -82,22 +82,22 @@ func (c *ClientTests) TestMultipleHooks() { requestHook2Called := false client.Hooks.AddRequestEventSubscriber( - easypost.RequestHookEventSubscriber{ - Callback: func(ctx context.Context, event easypost.RequestHookEvent) error { + RequestHookEventSubscriber{ + Callback: func(ctx context.Context, event RequestHookEvent) error { requestHook1Called = true return nil }, - HookEventSubscriber: easypost.HookEventSubscriber{ + HookEventSubscriber: HookEventSubscriber{ ID: "hook_1", }, }) client.Hooks.AddRequestEventSubscriber( - easypost.RequestHookEventSubscriber{ - Callback: func(ctx context.Context, event easypost.RequestHookEvent) error { + RequestHookEventSubscriber{ + Callback: func(ctx context.Context, event RequestHookEvent) error { requestHook2Called = true return nil }, - HookEventSubscriber: easypost.HookEventSubscriber{ + HookEventSubscriber: HookEventSubscriber{ ID: "hook_2", }, }) @@ -107,7 +107,7 @@ func (c *ClientTests) TestMultipleHooks() { // fire off a request _, err := client.ListAddresses( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -126,12 +126,12 @@ func (c *ClientTests) TestHooksUnsubscribing() { requestCallbackCallCount := 0 hookName := "hook_1" - subscriber := easypost.RequestHookEventSubscriber{ - Callback: func(ctx context.Context, event easypost.RequestHookEvent) error { + subscriber := RequestHookEventSubscriber{ + Callback: func(ctx context.Context, event RequestHookEvent) error { requestCallbackCallCount++ return nil }, - HookEventSubscriber: easypost.HookEventSubscriber{ + HookEventSubscriber: HookEventSubscriber{ ID: hookName, }, } @@ -143,7 +143,7 @@ func (c *ClientTests) TestHooksUnsubscribing() { // fire off a request _, err := client.ListAddresses( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -158,7 +158,7 @@ func (c *ClientTests) TestHooksUnsubscribing() { // fire off a request // fire off a request _, err = client.ListAddresses( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) diff --git a/tests/customs_info_test.go b/customs_info_test.go similarity index 75% rename from tests/customs_info_test.go rename to customs_info_test.go index 9e34b6e..f5bedbb 100644 --- a/tests/customs_info_test.go +++ b/customs_info_test.go @@ -1,10 +1,8 @@ -package easypost_test +package easypost import ( "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestCustomsInfoCreate() { @@ -14,7 +12,7 @@ func (c *ClientTests) TestCustomsInfoCreate() { customsInfo, err := client.CreateCustomsInfo(c.fixture.BasicCustomsInfo()) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.CustomsInfo{}), reflect.TypeOf(customsInfo)) + assert.Equal(reflect.TypeOf(&CustomsInfo{}), reflect.TypeOf(customsInfo)) assert.True(strings.HasPrefix(customsInfo.ID, "cstinfo_")) assert.Equal("NOEEI 30.37(a)", customsInfo.EELPFC) } @@ -29,6 +27,6 @@ func (c *ClientTests) TestCustomsInfoRetrieve() { retrievedCustomsInfo, err := client.GetCustomsInfo(customsInfo.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.CustomsInfo{}), reflect.TypeOf(retrievedCustomsInfo)) + assert.Equal(reflect.TypeOf(&CustomsInfo{}), reflect.TypeOf(retrievedCustomsInfo)) assert.Equal(customsInfo, retrievedCustomsInfo) } diff --git a/tests/customs_item_test.go b/customs_item_test.go similarity index 75% rename from tests/customs_item_test.go rename to customs_item_test.go index 7ab3293..f25d2e7 100644 --- a/tests/customs_item_test.go +++ b/customs_item_test.go @@ -1,10 +1,8 @@ -package easypost_test +package easypost import ( "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestCustomsItemCreate() { @@ -14,7 +12,7 @@ func (c *ClientTests) TestCustomsItemCreate() { customsItem, err := client.CreateCustomsItem(c.fixture.BasicCustomsItem()) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.CustomsItem{}), reflect.TypeOf(customsItem)) + assert.Equal(reflect.TypeOf(&CustomsItem{}), reflect.TypeOf(customsItem)) assert.True(strings.HasPrefix(customsItem.ID, "cstitem_")) assert.Equal(23.25, customsItem.Value) } @@ -29,6 +27,6 @@ func (c *ClientTests) TestCustomsItemRetrieve() { retrievedCustomsItem, err := client.GetCustomsItem(customsItem.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.CustomsItem{}), reflect.TypeOf(retrievedCustomsItem)) + assert.Equal(reflect.TypeOf(&CustomsItem{}), reflect.TypeOf(retrievedCustomsItem)) assert.Equal(customsItem, retrievedCustomsItem) } diff --git a/tests/datetime_test.go b/datetime_test.go similarity index 82% rename from tests/datetime_test.go rename to datetime_test.go index 89576c6..7c89205 100644 --- a/tests/datetime_test.go +++ b/datetime_test.go @@ -1,7 +1,6 @@ -package easypost_test +package easypost import ( - "github.com/EasyPost/easypost-go/v5" "reflect" "time" @@ -22,13 +21,13 @@ func (c *ClientTests) TestDateTime() { _time := time.Date(year, month, day, hour, minute, second, nanosecond, location) - datetime := easypost.DateTime(_time) + datetime := DateTime(_time) assert.Equal(_time, datetime.AsTime()) - datetimeFromTime := easypost.DateTimeFromTime(_time) + datetimeFromTime := DateTimeFromTime(_time) assert.Equal(_time, datetimeFromTime.AsTime()) - datetimeFromNumbers := easypost.NewDateTime(year, month, day, hour, minute, second, nanosecond, location) + datetimeFromNumbers := NewDateTime(year, month, day, hour, minute, second, nanosecond, location) assert.Equal(_time, datetimeFromNumbers.AsTime()) } @@ -47,7 +46,7 @@ func (c *ClientTests) TestDateTimeJSON() { pickup, err := client.CreatePickup(pickupData) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Pickup{}), reflect.TypeOf(pickup)) + assert.Equal(reflect.TypeOf(&Pickup{}), reflect.TypeOf(pickup)) assert.NotNil(pickup.MaxDatetime) assert.NotNil(pickup.MinDatetime) @@ -69,10 +68,10 @@ func (c *ClientTests) TestDateTimeUrlQueryStringParameterInclusion() { now := time.Now().UTC() past := now.AddDate(0, -4, 0) - start := easypost.DateTimeFromTime(past) - end := easypost.DateTimeFromTime(now) + start := DateTimeFromTime(past) + end := DateTimeFromTime(now) - options := easypost.ListOptions{ + options := ListOptions{ StartDateTime: &start, EndDateTime: &end, PageSize: 100, diff --git a/tests/easypost_test.go b/easypost_test.go similarity index 84% rename from tests/easypost_test.go rename to easypost_test.go index 176527d..9f3e15a 100644 --- a/tests/easypost_test.go +++ b/easypost_test.go @@ -1,15 +1,11 @@ -package easypost_test - -import ( - "github.com/EasyPost/easypost-go/v5" -) +package easypost func (c *ClientTests) TestClientTimeout() { timeout1 := 1000 timeout2 := 10 tempClient := c.TestClient() // set the timeout as part of the client initialization - client := &easypost.Client{ + client := &Client{ APIKey: tempClient.APIKey, Timeout: timeout1, } diff --git a/tests/endshipper_test.go b/endshipper_test.go similarity index 84% rename from tests/endshipper_test.go rename to endshipper_test.go index c3fdd04..2abb96e 100644 --- a/tests/endshipper_test.go +++ b/endshipper_test.go @@ -1,10 +1,8 @@ -package easypost_test +package easypost import ( "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestEndShipperCreate() { @@ -14,7 +12,7 @@ func (c *ClientTests) TestEndShipperCreate() { endshipper, err := client.CreateEndShipper(c.fixture.CaAddress1()) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Address{}), reflect.TypeOf(endshipper)) + assert.Equal(reflect.TypeOf(&Address{}), reflect.TypeOf(endshipper)) assert.True(strings.HasPrefix(endshipper.ID, "es")) assert.Equal("388 TOWNSEND ST APT 20", endshipper.Street1) } @@ -29,7 +27,7 @@ func (c *ClientTests) TestEndShipperRetrieve() { retrievedEndShipper, err := client.GetEndShipper(endshipper.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Address{}), reflect.TypeOf(retrievedEndShipper)) + assert.Equal(reflect.TypeOf(&Address{}), reflect.TypeOf(retrievedEndShipper)) assert.True(strings.HasPrefix(retrievedEndShipper.ID, "es")) assert.Equal(endshipper.Street1, retrievedEndShipper.Street1) } @@ -39,7 +37,7 @@ func (c *ClientTests) TestEndShipperAll() { assert, require := c.Assert(), c.Require() endshippers, err := client.ListEndShippers( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -48,7 +46,7 @@ func (c *ClientTests) TestEndShipperAll() { assert.LessOrEqual(len(endshippers.EndShippers), c.fixture.pageSize()) assert.NotNil(endshippers.HasMore) for _, endshipper := range endshippers.EndShippers { - assert.Equal(reflect.TypeOf(&easypost.Address{}), reflect.TypeOf(endshipper)) + assert.Equal(reflect.TypeOf(&Address{}), reflect.TypeOf(endshipper)) } } diff --git a/tests/error_test.go b/error_test.go similarity index 68% rename from tests/error_test.go rename to error_test.go index 2f5a13c..be5a67c 100644 --- a/tests/error_test.go +++ b/error_test.go @@ -1,12 +1,10 @@ -package easypost_test +package easypost import ( "errors" "io" "net/http" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestErrorInheritance() { @@ -16,22 +14,22 @@ func (c *ClientTests) TestErrorInheritance() { client.APIKey = "not-a-real-key" // Invalid API key will result in 403 Forbidden error _, err := client.CreateAddress( - &easypost.Address{ + &Address{ Street1: "", }, - &easypost.CreateAddressOptions{}, + &CreateAddressOptions{}, ) require.Error(err) // LibraryError is the base of all errors thrown in this library, error should be able to be cast to this - var libraryError *easypost.LibraryError + var libraryError *LibraryError if !errors.As(err, &libraryError) { assert.Fail("Error should be a LibraryError") } // APIError is the base of all errors thrown due to the API, error should be able to be cast to this - var apiError *easypost.APIError + var apiError *APIError if !errors.As(err, &apiError) { assert.Fail("Error should be an APIError") } @@ -39,13 +37,13 @@ func (c *ClientTests) TestErrorInheritance() { assert.Equal(403, apiError.StatusCode) // LocalError is the base of all errors thrown due to the library itself, and a subtype of LibraryError, but separate from APIError, error should NOT be able to be cast to this - var localError *easypost.LocalError + var localError *LocalError if errors.As(err, &localError) { assert.Fail("Error should not be a LocalError") } // ForbiddenError is an error due to a 403 status code, and a subtype of APIError, error should be able to be cast to this - var forbiddenError *easypost.ForbiddenError + var forbiddenError *ForbiddenError if !errors.As(err, &forbiddenError) { assert.Fail("Error should be a ForbiddenError") } @@ -65,18 +63,18 @@ func (c *ClientTests) TestApiError() { assert, require := c.Assert(), c.Require() // Create a bad shipment so we can work with errors - _, err := client.CreateShipment(&easypost.Shipment{}) + _, err := client.CreateShipment(&Shipment{}) require.Error(err) - var invalidRequestError *easypost.InvalidRequestError + var invalidRequestError *InvalidRequestError if errors.As(err, &invalidRequestError) { assert.Equal(422, invalidRequestError.StatusCode) assert.Equal("PARAMETER.REQUIRED", invalidRequestError.Code) assert.Equal("Missing required parameter.", invalidRequestError.Message) if errorsList, ok := invalidRequestError.Errors.([]interface{}); ok { assert.Equal(1, len(errorsList)) - if fieldError, ok := errorsList[0].(*easypost.FieldError); ok { + if fieldError, ok := errorsList[0].(*FieldError); ok { assert.Equal("shipment", fieldError.Field) assert.Equal("cannot be blank", fieldError.Message) } @@ -100,7 +98,7 @@ func (c *ClientTests) TestApiErrorAlternativeFormat() { require.Error(err) - var notFoundError *easypost.NotFoundError + var notFoundError *NotFoundError if errors.As(err, ¬FoundError) { assert.Equal(404, notFoundError.StatusCode) assert.Equal("NOT_FOUND", notFoundError.Code) @@ -125,143 +123,143 @@ func (c *ClientTests) TestApiErrorStatusCodes() { } res.StatusCode = 0 - err := easypost.BuildErrorFromResponse(res) - ok := errors.As(err, new(*easypost.ConnectionError)) + err := BuildErrorFromResponse(res) + ok := errors.As(err, new(*ConnectionError)) assert.True(ok) res.StatusCode = 100 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.RetryError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*RetryError)) assert.True(ok) res.StatusCode = 101 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.RetryError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*RetryError)) assert.True(ok) res.StatusCode = 102 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.RetryError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*RetryError)) assert.True(ok) res.StatusCode = 103 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.RetryError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*RetryError)) assert.True(ok) res.StatusCode = 300 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.RedirectError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*RedirectError)) assert.True(ok) res.StatusCode = 301 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.RedirectError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*RedirectError)) assert.True(ok) res.StatusCode = 302 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.RedirectError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*RedirectError)) assert.True(ok) res.StatusCode = 303 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.RedirectError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*RedirectError)) assert.True(ok) res.StatusCode = 304 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.RedirectError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*RedirectError)) assert.True(ok) res.StatusCode = 305 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.RedirectError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*RedirectError)) assert.True(ok) res.StatusCode = 306 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.RedirectError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*RedirectError)) assert.True(ok) res.StatusCode = 307 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.RedirectError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*RedirectError)) assert.True(ok) res.StatusCode = 308 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.RedirectError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*RedirectError)) assert.True(ok) res.StatusCode = 400 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.BadRequestError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*BadRequestError)) assert.True(ok) res.StatusCode = 401 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.UnauthorizedError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*UnauthorizedError)) assert.True(ok) res.StatusCode = 402 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.PaymentError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*PaymentError)) assert.True(ok) res.StatusCode = 403 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.ForbiddenError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*ForbiddenError)) assert.True(ok) res.StatusCode = 404 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.NotFoundError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*NotFoundError)) assert.True(ok) res.StatusCode = 405 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.MethodNotAllowedError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*MethodNotAllowedError)) assert.True(ok) res.StatusCode = 407 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.ProxyError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*ProxyError)) assert.True(ok) res.StatusCode = 408 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.TimeoutError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*TimeoutError)) assert.True(ok) res.StatusCode = 422 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.InvalidRequestError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*InvalidRequestError)) assert.True(ok) res.StatusCode = 429 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.RateLimitError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*RateLimitError)) assert.True(ok) res.StatusCode = 500 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.InternalServerError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*InternalServerError)) assert.True(ok) res.StatusCode = 503 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.ServiceUnavailableError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*ServiceUnavailableError)) assert.True(ok) res.StatusCode = 504 - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.GatewayTimeoutError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*GatewayTimeoutError)) assert.True(ok) res.StatusCode = 7000 // unaccounted for status code - err = easypost.BuildErrorFromResponse(res) - ok = errors.As(err, new(*easypost.UnknownHttpError)) + err = BuildErrorFromResponse(res) + ok = errors.As(err, new(*UnknownHttpError)) assert.True(ok) } @@ -282,7 +280,7 @@ func (c *ClientTests) TestApiErrorMessageParseArray() { Body: io.NopCloser(strings.NewReader(fakeErrorResponse)), } - err := easypost.BuildErrorFromResponse(res) + err := BuildErrorFromResponse(res) errorMessage := err.Error() assert.Equal("UNPROCESSABLE_ENTITY Bad format, Bad format 2", errorMessage) @@ -309,7 +307,7 @@ func (c *ClientTests) TestErrorMessageParseMap() { Body: io.NopCloser(strings.NewReader(fakeErrorResponse)), } - err := easypost.BuildErrorFromResponse(res) + err := BuildErrorFromResponse(res) errorMessage := err.Error() assert.Equal("UNPROCESSABLE_ENTITY Bad format, Bad format 2", errorMessage) @@ -348,7 +346,7 @@ func (c *ClientTests) TestErrorMessageParseExtreme() { Body: io.NopCloser(strings.NewReader(fakeErrorResponse)), } - err := easypost.BuildErrorFromResponse(res) + err := BuildErrorFromResponse(res) errorMessage := err.Error() messages := []string{"message1", "message2", "message3", "message4", "message5", "message6"} diff --git a/tests/event_test.go b/event_test.go similarity index 88% rename from tests/event_test.go rename to event_test.go index 35b2b3a..d8bacf1 100644 --- a/tests/event_test.go +++ b/event_test.go @@ -1,4 +1,4 @@ -package easypost_test +package easypost import ( "errors" @@ -7,8 +7,6 @@ import ( "reflect" "strings" "time" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestEventAll() { @@ -16,7 +14,7 @@ func (c *ClientTests) TestEventAll() { assert, require := c.Assert(), c.Require() events, err := client.ListEvents( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -27,7 +25,7 @@ func (c *ClientTests) TestEventAll() { assert.LessOrEqual(len(eventsList), c.fixture.pageSize()) assert.NotNil(events.HasMore) for _, event := range eventsList { - assert.Equal(reflect.TypeOf(&easypost.Event{}), reflect.TypeOf(event)) + assert.Equal(reflect.TypeOf(&Event{}), reflect.TypeOf(event)) } } @@ -36,7 +34,7 @@ func (c *ClientTests) TestEventRetrieve() { assert, require := c.Assert(), c.Require() events, err := client.ListEvents( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -45,7 +43,7 @@ func (c *ClientTests) TestEventRetrieve() { event, err := client.GetEvent(events.Events[0].ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Event{}), reflect.TypeOf(event)) + assert.Equal(reflect.TypeOf(&Event{}), reflect.TypeOf(event)) assert.True(strings.HasPrefix(event.ID, "evt_")) } @@ -55,7 +53,7 @@ func (c *ClientTests) TestEventRetrieveAllPayloads() { // Create a webhook to receive the event webhook, webhookErr := client.CreateWebhook( - &easypost.CreateUpdateWebhookOptions{ + &CreateUpdateWebhookOptions{ URL: c.fixture.WebhookUrl(), }, ) @@ -75,7 +73,7 @@ func (c *ClientTests) TestEventRetrieveAllPayloads() { // Retrieve all events and extract the newest one events, err := client.ListEvents( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -98,7 +96,7 @@ func (c *ClientTests) TestEventRetrievePayload() { // Create a webhook to receive the event webhook, webhookErr := client.CreateWebhook( - &easypost.CreateUpdateWebhookOptions{ + &CreateUpdateWebhookOptions{ URL: c.fixture.WebhookUrl(), }, ) @@ -117,7 +115,7 @@ func (c *ClientTests) TestEventRetrievePayload() { } events, err := client.ListEvents( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -136,7 +134,7 @@ func (c *ClientTests) TestEventsGetNextPage() { assert, require := c.Assert(), c.Require() firstPage, err := client.ListEvents( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -154,7 +152,7 @@ func (c *ClientTests) TestEventsGetNextPage() { } }() if err != nil { - assert.Equal(easypost.NoPagesLeftToRetrieve, err.Error()) + assert.Equal(NoPagesLeftToRetrieve, err.Error()) return } } diff --git a/tests/fixture_test.go b/fixture_test.go similarity index 52% rename from tests/fixture_test.go rename to fixture_test.go index f68534f..1d67acf 100644 --- a/tests/fixture_test.go +++ b/fixture_test.go @@ -1,4 +1,4 @@ -package easypost_test +package easypost import ( "bufio" @@ -6,48 +6,43 @@ import ( "fmt" "io" "os" - "path/filepath" "time" - - "github.com/EasyPost/easypost-go/v5" ) type Fixture struct { - Addresses map[string]*easypost.Address `json:"addresses,omitempty" url:"addresses,omitempty"` - Billing billingFixture `json:"billing,omitempty" url:"billing,omitempty"` - CarrierAccounts map[string]*easypost.CarrierAccount `json:"carrier_accounts,omitempty" url:"carrier_accounts,omitempty"` - CarrierStrings map[string]string `json:"carrier_strings,omitempty" url:"carrier_strings,omitempty"` - Claims map[string]*easypost.CreateClaimParameters `json:"claims,omitempty" url:"claims,omitempty"` - CustomsInfos map[string]*easypost.CustomsInfo `json:"customs_infos,omitempty" url:"customs_infos,omitempty"` - CustomsItems map[string]*easypost.CustomsItem `json:"customs_items,omitempty" url:"customs_items,omitempty"` - CreditCards map[string]*easypost.CreditCardOptions `json:"credit_cards,omitempty" url:"credit_cards,omitempty"` - FormOptions map[string]map[string]interface{} `json:"form_options,omitempty" url:"form_options,omitempty"` - Insurances map[string]*easypost.Insurance `json:"insurances,omitempty" url:"insurances,omitempty"` - Luma map[string]interface{} `json:"luma,omitempty" url:"luma,omitempty"` - Orders map[string]*easypost.Order `json:"orders,omitempty" url:"orders,omitempty"` - PageSizes map[string]int `json:"page_sizes,omitempty" url:"page_sizes,omitempty"` - Parcels map[string]*easypost.Parcel `json:"parcels,omitempty" url:"parcels,omitempty"` - Pickups map[string]*easypost.Pickup `json:"pickups,omitempty" url:"pickups,omitempty"` - ReportTypes map[string]string `json:"report_types,omitempty" url:"report_types,omitempty"` - ServiceNames map[string]map[string]string `json:"service_names,omitempty" url:"service_names,omitempty"` - Shipments map[string]*easypost.Shipment `json:"shipments,omitempty" url:"shipments,omitempty"` - TaxIdentifiers map[string]*easypost.TaxIdentifier `json:"tax_identifiers,omitempty" url:"tax_identifiers,omitempty"` - Users map[string]*easypost.UserOptions `json:"users,omitempty" url:"users,omitempty"` - Webhooks map[string]interface{} `json:"webhooks,omitempty" url:"webhooks,omitempty"` + Addresses map[string]*Address `json:"addresses,omitempty" url:"addresses,omitempty"` + Billing billingFixture `json:"billing,omitempty" url:"billing,omitempty"` + CarrierAccounts map[string]*CarrierAccount `json:"carrier_accounts,omitempty" url:"carrier_accounts,omitempty"` + CarrierStrings map[string]string `json:"carrier_strings,omitempty" url:"carrier_strings,omitempty"` + Claims map[string]*CreateClaimParameters `json:"claims,omitempty" url:"claims,omitempty"` + CustomsInfos map[string]*CustomsInfo `json:"customs_infos,omitempty" url:"customs_infos,omitempty"` + CustomsItems map[string]*CustomsItem `json:"customs_items,omitempty" url:"customs_items,omitempty"` + CreditCards map[string]*CreditCardOptions `json:"credit_cards,omitempty" url:"credit_cards,omitempty"` + FormOptions map[string]map[string]interface{} `json:"form_options,omitempty" url:"form_options,omitempty"` + Insurances map[string]*Insurance `json:"insurances,omitempty" url:"insurances,omitempty"` + Luma map[string]interface{} `json:"luma,omitempty" url:"luma,omitempty"` + Orders map[string]*Order `json:"orders,omitempty" url:"orders,omitempty"` + PageSizes map[string]int `json:"page_sizes,omitempty" url:"page_sizes,omitempty"` + Parcels map[string]*Parcel `json:"parcels,omitempty" url:"parcels,omitempty"` + Pickups map[string]*Pickup `json:"pickups,omitempty" url:"pickups,omitempty"` + ReportTypes map[string]string `json:"report_types,omitempty" url:"report_types,omitempty"` + ServiceNames map[string]map[string]string `json:"service_names,omitempty" url:"service_names,omitempty"` + Shipments map[string]*Shipment `json:"shipments,omitempty" url:"shipments,omitempty"` + TaxIdentifiers map[string]*TaxIdentifier `json:"tax_identifiers,omitempty" url:"tax_identifiers,omitempty"` + Users map[string]*UserOptions `json:"users,omitempty" url:"users,omitempty"` + Webhooks map[string]interface{} `json:"webhooks,omitempty" url:"webhooks,omitempty"` } type billingFixture struct { - PaymentMethodID string `json:"payment_method_id,omitempty" url:"payment_method_id,omitempty"` - FinancialConnectionsID string `json:"financial_connections_id,omitempty" url:"financial_connections_id,omitempty"` - MandateData *easypost.MandateData `json:"mandate_data,omitempty" url:"mandate_data,omitempty"` - Priority string `json:"priority,omitempty" url:"priority,omitempty"` + PaymentMethodID string `json:"payment_method_id,omitempty" url:"payment_method_id,omitempty"` + FinancialConnectionsID string `json:"financial_connections_id,omitempty" url:"financial_connections_id,omitempty"` + MandateData *MandateData `json:"mandate_data,omitempty" url:"mandate_data,omitempty"` + Priority string `json:"priority,omitempty" url:"priority,omitempty"` } // Reads fixture data from the fixtures JSON file func readFixtureData() Fixture { - currentDir, _ := os.Getwd() - parentDir := filepath.Dir(currentDir) - filePath := fmt.Sprintf("%s%s", parentDir, "/examples/official/fixtures/client-library-fixtures.json") + filePath := "examples/official/fixtures/client-library-fixtures.json" /* #nosec */ data, err := os.Open(filePath) @@ -103,23 +98,23 @@ func (fixture *Fixture) ReportDate() string { return "2022-04-11" } -func (fixture *Fixture) CaAddress1() *easypost.Address { +func (fixture *Fixture) CaAddress1() *Address { return readFixtureData().Addresses["ca_address_1"] } -func (fixture *Fixture) CaAddress2() *easypost.Address { +func (fixture *Fixture) CaAddress2() *Address { return readFixtureData().Addresses["ca_address_2"] } -func (fixture *Fixture) IncorrectAddress() *easypost.Address { +func (fixture *Fixture) IncorrectAddress() *Address { return readFixtureData().Addresses["incorrect"] } -func (fixture *Fixture) BasicParcel() *easypost.Parcel { +func (fixture *Fixture) BasicParcel() *Parcel { return readFixtureData().Parcels["basic"] } -func (fixture *Fixture) BasicCustomsItem() *easypost.CustomsItem { +func (fixture *Fixture) BasicCustomsItem() *CustomsItem { customsItem := readFixtureData().CustomsItems["basic"] // Json unmarshalling doesn't handle float64 well, need to manually set the value @@ -128,7 +123,7 @@ func (fixture *Fixture) BasicCustomsItem() *easypost.CustomsItem { return customsItem } -func (fixture *Fixture) BasicCustomsInfo() *easypost.CustomsInfo { +func (fixture *Fixture) BasicCustomsInfo() *CustomsInfo { customsInfo := readFixtureData().CustomsInfos["basic"] // Json unmarshalling doesn't handle float64 well, need to manually set the value @@ -138,20 +133,20 @@ func (fixture *Fixture) BasicCustomsInfo() *easypost.CustomsInfo { return customsInfo } -func (fixture *Fixture) TaxIdentifier() *easypost.TaxIdentifier { +func (fixture *Fixture) TaxIdentifier() *TaxIdentifier { return readFixtureData().TaxIdentifiers["basic"] } -func (fixture *Fixture) BasicShipment() *easypost.Shipment { +func (fixture *Fixture) BasicShipment() *Shipment { return readFixtureData().Shipments["basic_domestic"] } -func (fixture *Fixture) FullShipment() *easypost.Shipment { +func (fixture *Fixture) FullShipment() *Shipment { return readFixtureData().Shipments["full"] } -func (fixture *Fixture) OneCallBuyShipment() *easypost.Shipment { - return &easypost.Shipment{ +func (fixture *Fixture) OneCallBuyShipment() *Shipment { + return &Shipment{ ToAddress: fixture.CaAddress1(), FromAddress: fixture.CaAddress2(), Parcel: fixture.BasicParcel(), @@ -164,8 +159,8 @@ func (fixture *Fixture) OneCallBuyShipment() *easypost.Shipment { // This fixture will require you to add a `shipment` key with a Shipment object from a test. // If you need to re-record cassettes, increment the date below and ensure it is one day in the future, // USPS only does "next-day" pickups including Saturday but not Sunday or Holidays. -func (fixture *Fixture) BasicPickup() *easypost.Pickup { - pickupDate := easypost.NewDateTime(2024, time.August, 14, 0, 0, 0, 0, time.UTC) +func (fixture *Fixture) BasicPickup() *Pickup { + pickupDate := NewDateTime(2024, time.August, 14, 0, 0, 0, 0, time.UTC) pickupData := readFixtureData().Pickups["basic"] pickupData.MinDatetime = &pickupDate @@ -174,28 +169,26 @@ func (fixture *Fixture) BasicPickup() *easypost.Pickup { return pickupData } -func (fixture *Fixture) BasicCarrierAccount() *easypost.CarrierAccount { +func (fixture *Fixture) BasicCarrierAccount() *CarrierAccount { return readFixtureData().CarrierAccounts["basic"] } // This fixture will require you to add a `tracking_code` key with a tracking code from a shipment -func (fixture *Fixture) BasicInsurance() *easypost.Insurance { +func (fixture *Fixture) BasicInsurance() *Insurance { return readFixtureData().Insurances["basic"] } // This fixture will require you to add a `tracking_code` key with a tracking code from a shipment and an `amount` key with a float value -func (fixture *Fixture) BasicClaim() *easypost.CreateClaimParameters { +func (fixture *Fixture) BasicClaim() *CreateClaimParameters { return readFixtureData().Claims["basic"] } -func (fixture *Fixture) BasicOrder() *easypost.Order { +func (fixture *Fixture) BasicOrder() *Order { return readFixtureData().Orders["basic"] } func (fixture *Fixture) EventBody() []byte { - currentDir, _ := os.Getwd() - parentDir := filepath.Dir(currentDir) - filePath := fmt.Sprintf("%s%s", parentDir, "/examples/official/fixtures/event-body.json") + filePath := "examples/official/fixtures/event-body.json" /* #nosec */ data, err := os.Open(filePath) @@ -228,8 +221,8 @@ func (fixture *Fixture) WebhookUrl() string { return readFixtureData().Webhooks["url"].(string) } -func (fixture *Fixture) WebhookCustomHeaders() []easypost.WebhookCustomHeader { - var header easypost.WebhookCustomHeader +func (fixture *Fixture) WebhookCustomHeaders() []WebhookCustomHeader { + var header WebhookCustomHeader inputCustomHeaders := readFixtureData().Webhooks["custom_headers"] customHeaders := inputCustomHeaders.([]interface{}) @@ -237,7 +230,7 @@ func (fixture *Fixture) WebhookCustomHeaders() []easypost.WebhookCustomHeader { header.Name = headerMap["name"].(string) header.Value = headerMap["value"].(string) - webhookCustomHeaders := []easypost.WebhookCustomHeader{header} + webhookCustomHeaders := []WebhookCustomHeader{header} return webhookCustomHeaders } @@ -246,11 +239,11 @@ func (fixture *Fixture) RmaFormOptions() map[string]interface{} { return readFixtureData().FormOptions["rma"] } -func (fixture *Fixture) ReferralUser() *easypost.UserOptions { +func (fixture *Fixture) ReferralUser() *UserOptions { return readFixtureData().Users["referral"] } -func (fixture *Fixture) TestCreditCard() *easypost.CreditCardOptions { +func (fixture *Fixture) TestCreditCard() *CreditCardOptions { return readFixtureData().CreditCards["test"] } diff --git a/tests/insurance_test.go b/insurance_test.go similarity index 83% rename from tests/insurance_test.go rename to insurance_test.go index 95828d0..7f74a2a 100644 --- a/tests/insurance_test.go +++ b/insurance_test.go @@ -1,11 +1,9 @@ -package easypost_test +package easypost import ( "errors" "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestInsuranceCreate() { @@ -21,7 +19,7 @@ func (c *ClientTests) TestInsuranceCreate() { insurance, err := client.CreateInsurance(insuranceData) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Insurance{}), reflect.TypeOf(insurance)) + assert.Equal(reflect.TypeOf(&Insurance{}), reflect.TypeOf(insurance)) assert.True(strings.HasPrefix(insurance.ID, "ins_")) assert.Equal("100.00000", insurance.Amount) } @@ -31,7 +29,7 @@ func (c *ClientTests) TestInsuranceRetrieve() { assert, require := c.Assert(), c.Require() insurances, err := client.ListInsurances( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -40,7 +38,7 @@ func (c *ClientTests) TestInsuranceRetrieve() { retrievedInsurance, err := client.GetInsurance(insurances.Insurances[0].ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Insurance{}), reflect.TypeOf(retrievedInsurance)) + assert.Equal(reflect.TypeOf(&Insurance{}), reflect.TypeOf(retrievedInsurance)) assert.Equal(insurances.Insurances[0], retrievedInsurance) } @@ -49,7 +47,7 @@ func (c *ClientTests) TestInsuranceAll() { assert, require := c.Assert(), c.Require() insurances, err := client.ListInsurances( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -60,7 +58,7 @@ func (c *ClientTests) TestInsuranceAll() { assert.LessOrEqual(len(insurancesList), c.fixture.pageSize()) assert.NotNil(insurances.HasMore) for _, insurance := range insurancesList { - assert.Equal(reflect.TypeOf(&easypost.Insurance{}), reflect.TypeOf(insurance)) + assert.Equal(reflect.TypeOf(&Insurance{}), reflect.TypeOf(insurance)) } } @@ -69,7 +67,7 @@ func (c *ClientTests) TestInsuranceGetNextPage() { assert, require := c.Assert(), c.Require() firstPage, err := client.ListInsurances( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -87,7 +85,7 @@ func (c *ClientTests) TestInsuranceGetNextPage() { } }() if err != nil { - var endOfPaginationErr *easypost.EndOfPaginationError + var endOfPaginationErr *EndOfPaginationError if errors.As(err, &endOfPaginationErr) { assert.Equal(err.Error(), endOfPaginationErr.Error()) return @@ -107,7 +105,7 @@ func (c *ClientTests) TestInsuranceRefund() { refundInsurance, err := client.RefundInsurance(insurance.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Insurance{}), reflect.TypeOf(refundInsurance)) + assert.Equal(reflect.TypeOf(&Insurance{}), reflect.TypeOf(refundInsurance)) assert.True(strings.HasPrefix(refundInsurance.ID, "ins_")) assert.Equal("cancelled", refundInsurance.Status) assert.Equal("Insurance was cancelled by the user.", refundInsurance.Messages[0]) diff --git a/tests/luma_test.go b/luma_test.go similarity index 79% rename from tests/luma_test.go rename to luma_test.go index 1d4ecbd..5c0e8ed 100644 --- a/tests/luma_test.go +++ b/luma_test.go @@ -1,15 +1,11 @@ -package easypost_test - -import ( - "github.com/EasyPost/easypost-go/v5" -) +package easypost func (c *ClientTests) TestGetLumaPromise() { client := c.TestClient() assert, require := c.Assert(), c.Require() shipmentData := c.fixture.BasicShipment() - lumaRequest := easypost.LumaRequest{ + lumaRequest := LumaRequest{ Shipment: *shipmentData, RulesetName: c.fixture.LumaRulesetName(), PlannedShipDate: c.fixture.LumaPlannedShipDate(), diff --git a/tests/order_test.go b/order_test.go similarity index 86% rename from tests/order_test.go rename to order_test.go index 2693391..fa7414d 100644 --- a/tests/order_test.go +++ b/order_test.go @@ -1,10 +1,8 @@ -package easypost_test +package easypost import ( "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestOrderCreate() { @@ -14,7 +12,7 @@ func (c *ClientTests) TestOrderCreate() { order, err := client.CreateOrder(c.fixture.BasicOrder()) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Order{}), reflect.TypeOf(order)) + assert.Equal(reflect.TypeOf(&Order{}), reflect.TypeOf(order)) assert.True(strings.HasPrefix(order.ID, "order_")) assert.NotNil(order.Rates) } @@ -29,7 +27,7 @@ func (c *ClientTests) TestOrderRetrieve() { retrievedOrder, err := client.GetOrder(order.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Order{}), reflect.TypeOf(retrievedOrder)) + assert.Equal(reflect.TypeOf(&Order{}), reflect.TypeOf(retrievedOrder)) assert.Equal(order.ID, retrievedOrder.ID) } @@ -45,9 +43,9 @@ func (c *ClientTests) TestOrderGetRates() { ratesList := rates.Rates - assert.Equal(reflect.TypeOf([]*easypost.Rate{}), reflect.TypeOf(ratesList)) + assert.Equal(reflect.TypeOf([]*Rate{}), reflect.TypeOf(ratesList)) for _, rate := range ratesList { - assert.Equal(reflect.TypeOf(&easypost.Rate{}), reflect.TypeOf(rate)) + assert.Equal(reflect.TypeOf(&Rate{}), reflect.TypeOf(rate)) } } diff --git a/tests/paginated_collection_test.go b/paginated_collection_test.go similarity index 82% rename from tests/paginated_collection_test.go rename to paginated_collection_test.go index ba1b36e..99e32a8 100644 --- a/tests/paginated_collection_test.go +++ b/paginated_collection_test.go @@ -1,9 +1,7 @@ -package easypost_test +package easypost import ( "errors" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestGetNextPage() { @@ -11,7 +9,7 @@ func (c *ClientTests) TestGetNextPage() { assert, require := c.Assert(), c.Require() addresses, err := client.ListAddresses( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -27,7 +25,7 @@ func (c *ClientTests) TestGetNextPage() { } }() if err != nil { - var endOfPaginationErr *easypost.EndOfPaginationError + var endOfPaginationErr *EndOfPaginationError if errors.As(err, &endOfPaginationErr) { assert.Equal(err.Error(), endOfPaginationErr.Error()) return @@ -41,7 +39,7 @@ func (c *ClientTests) TestGetNextPageWithPageSize() { assert, require := c.Assert(), c.Require() addresses, err := client.ListAddresses( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -59,7 +57,7 @@ func (c *ClientTests) TestGetNextPageWithPageSize() { } }() if err != nil { - var endOfPaginationErr *easypost.EndOfPaginationError + var endOfPaginationErr *EndOfPaginationError if errors.As(err, &endOfPaginationErr) { assert.Equal(err.Error(), endOfPaginationErr.Error()) return @@ -69,13 +67,13 @@ func (c *ClientTests) TestGetNextPageWithPageSize() { } func (c *ClientTests) TestGetNextPageReachEnd() { - mockRequests := []easypost.MockRequest{ + mockRequests := []MockRequest{ { - MatchRule: easypost.MockRequestMatchRule{ + MatchRule: MockRequestMatchRule{ Method: "GET", UrlRegexPattern: "v2\\/addresses", }, - ResponseInfo: easypost.MockRequestResponseInfo{ + ResponseInfo: MockRequestResponseInfo{ StatusCode: 200, Body: `{"addresses": [], "has_more": false}`, }, @@ -86,7 +84,7 @@ func (c *ClientTests) TestGetNextPageReachEnd() { assert, require := c.Assert(), c.Require() addresses, err := client.ListAddresses( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -97,7 +95,7 @@ func (c *ClientTests) TestGetNextPageReachEnd() { for { addresses, err = client.GetNextAddressPage(addresses) if err != nil { - var endOfPaginationErr *easypost.EndOfPaginationError + var endOfPaginationErr *EndOfPaginationError if errors.As(err, &endOfPaginationErr) { hitEnd = true } else { diff --git a/tests/parcel_test.go b/parcel_test.go similarity index 74% rename from tests/parcel_test.go rename to parcel_test.go index d96489c..e440af4 100644 --- a/tests/parcel_test.go +++ b/parcel_test.go @@ -1,10 +1,8 @@ -package easypost_test +package easypost import ( "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestParcelCreate() { @@ -14,7 +12,7 @@ func (c *ClientTests) TestParcelCreate() { parcel, err := client.CreateParcel(c.fixture.BasicParcel()) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Parcel{}), reflect.TypeOf(parcel)) + assert.Equal(reflect.TypeOf(&Parcel{}), reflect.TypeOf(parcel)) assert.True(strings.HasPrefix(parcel.ID, "prcl_")) assert.Equal(15.4, parcel.Weight) } @@ -29,6 +27,6 @@ func (c *ClientTests) TestParcelRetrieve() { retrievedParcel, err := client.GetParcel(parcel.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Parcel{}), reflect.TypeOf(retrievedParcel)) + assert.Equal(reflect.TypeOf(&Parcel{}), reflect.TypeOf(retrievedParcel)) assert.Equal(parcel, retrievedParcel) } diff --git a/tests/pickup_test.go b/pickup_test.go similarity index 87% rename from tests/pickup_test.go rename to pickup_test.go index 2e39a12..9960d45 100644 --- a/tests/pickup_test.go +++ b/pickup_test.go @@ -1,11 +1,9 @@ -package easypost_test +package easypost import ( "errors" "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestPickupCreate() { @@ -21,7 +19,7 @@ func (c *ClientTests) TestPickupCreate() { pickup, err := client.CreatePickup(pickupData) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Pickup{}), reflect.TypeOf(pickup)) + assert.Equal(reflect.TypeOf(&Pickup{}), reflect.TypeOf(pickup)) assert.True(strings.HasPrefix(pickup.ID, "pickup_")) assert.NotNil(pickup.PickupRates) } @@ -42,7 +40,7 @@ func (c *ClientTests) TestPickupRetrieve() { retrievePickup, err := client.GetPickup(pickup.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Pickup{}), reflect.TypeOf(retrievePickup)) + assert.Equal(reflect.TypeOf(&Pickup{}), reflect.TypeOf(retrievePickup)) assert.Equal(pickup.ID, retrievePickup.ID) } @@ -61,14 +59,14 @@ func (c *ClientTests) TestPickupBuy() { boughtPickup, err := client.BuyPickup( pickup.ID, - &easypost.PickupRate{ + &PickupRate{ Carrier: c.fixture.USPS(), Service: c.fixture.PickupService(), }, ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Pickup{}), reflect.TypeOf(boughtPickup)) + assert.Equal(reflect.TypeOf(&Pickup{}), reflect.TypeOf(boughtPickup)) assert.True(strings.HasPrefix(boughtPickup.ID, "pickup_")) assert.NotNil(pickup.Confirmation) assert.Equal("scheduled", boughtPickup.Status) @@ -89,7 +87,7 @@ func (c *ClientTests) TestPickupCancel() { boughtPickup, err := client.BuyPickup( pickup.ID, - &easypost.PickupRate{ + &PickupRate{ Carrier: c.fixture.USPS(), Service: c.fixture.PickupService(), }, @@ -99,7 +97,7 @@ func (c *ClientTests) TestPickupCancel() { cancelledPickup, err := client.CancelPickup(boughtPickup.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Pickup{}), reflect.TypeOf(cancelledPickup)) + assert.Equal(reflect.TypeOf(&Pickup{}), reflect.TypeOf(cancelledPickup)) assert.True(strings.HasPrefix(cancelledPickup.ID, "pickup_")) assert.Equal("canceled", cancelledPickup.Status) } @@ -138,7 +136,7 @@ func (c *ClientTests) TestPickupAll() { assert, require := c.Assert(), c.Require() pickups, err := client.ListPickups( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -147,7 +145,7 @@ func (c *ClientTests) TestPickupAll() { assert.LessOrEqual(len(pickups.Pickups), c.fixture.pageSize()) assert.NotNil(pickups.HasMore) for _, pickup := range pickups.Pickups { - assert.Equal(reflect.TypeOf(&easypost.Pickup{}), reflect.TypeOf(pickup)) + assert.Equal(reflect.TypeOf(&Pickup{}), reflect.TypeOf(pickup)) } } @@ -156,7 +154,7 @@ func (c *ClientTests) TestPickupsGetNextPage() { assert, require := c.Assert(), c.Require() firstPage, err := client.ListPickups( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -174,7 +172,7 @@ func (c *ClientTests) TestPickupsGetNextPage() { } }() if err != nil { - var endOfPaginationErr *easypost.EndOfPaginationError + var endOfPaginationErr *EndOfPaginationError if errors.As(err, &endOfPaginationErr) { assert.Equal(err.Error(), endOfPaginationErr.Error()) return diff --git a/tests/rate_test.go b/rate_test.go similarity index 82% rename from tests/rate_test.go rename to rate_test.go index 13a6807..8c12c87 100644 --- a/tests/rate_test.go +++ b/rate_test.go @@ -1,10 +1,8 @@ -package easypost_test +package easypost import ( "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestRateRetrieve() { @@ -17,7 +15,7 @@ func (c *ClientTests) TestRateRetrieve() { rate, err := client.GetRate(shipment.Rates[0].ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Rate{}), reflect.TypeOf(rate)) + assert.Equal(reflect.TypeOf(&Rate{}), reflect.TypeOf(rate)) assert.True(strings.HasPrefix(rate.ID, "rate_")) } @@ -28,7 +26,7 @@ func (c *ClientTests) TestBetaStatelessRateRetrieve() { rates, err := client.BetaGetStatelessRates(c.fixture.BasicShipment()) require.NoError(err) - assert.Equal(reflect.TypeOf([]*easypost.StatelessRate{}), reflect.TypeOf(rates)) + assert.Equal(reflect.TypeOf([]*StatelessRate{}), reflect.TypeOf(rates)) } func (c *ClientTests) TestBetaStatelessRateGetLowest() { @@ -41,7 +39,7 @@ func (c *ClientTests) TestBetaStatelessRateGetLowest() { lowestRate, err := client.LowestStatelessRate(rates) require.NoError(err) - assert.Equal(reflect.TypeOf(easypost.StatelessRate{}), reflect.TypeOf(lowestRate)) + assert.Equal(reflect.TypeOf(StatelessRate{}), reflect.TypeOf(lowestRate)) assert.Equal("GroundAdvantage", lowestRate.Service) } diff --git a/tests/referral_customer_test.go b/referral_customer_test.go similarity index 84% rename from tests/referral_customer_test.go rename to referral_customer_test.go index fbed772..7136b58 100644 --- a/tests/referral_customer_test.go +++ b/referral_customer_test.go @@ -1,21 +1,19 @@ -package easypost_test +package easypost import ( "errors" "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestBetaReferralAddPaymentMethod() { client := c.ReferralClient() assert, require := c.Assert(), c.Require() - _, err := client.BetaAddPaymentMethod("cus_123", "ba_123", easypost.PrimaryPaymentMethodPriority) + _, err := client.BetaAddPaymentMethod("cus_123", "ba_123", PrimaryPaymentMethodPriority) require.Error(err) - var eperr *easypost.APIError + var eperr *APIError if errors.As(err, &eperr) { assert.Equal(422, eperr.StatusCode) assert.Equal("BILLING.INVALID_PAYMENT_GATEWAY_REFERENCE", eperr.Code) @@ -30,7 +28,7 @@ func (c *ClientTests) TestBetaReferralRefundByAmount() { _, err := client.BetaRefundByAmount(2000) require.Error(err) - var eperr *easypost.APIError + var eperr *APIError if errors.As(err, &eperr) { assert.Equal(422, eperr.StatusCode) assert.Equal("TRANSACTION.AMOUNT_INVALID", eperr.Code) @@ -45,7 +43,7 @@ func (c *ClientTests) TestBetaReferralRefundByPaymentLogId() { _, err := client.BetaRefundByPaymentLog("paylog_...") require.Error(err) - var eperr *easypost.APIError + var eperr *APIError if errors.As(err, &eperr) { assert.Equal(422, eperr.StatusCode) assert.Equal("TRANSACTION.DOES_NOT_EXIST", eperr.Code) @@ -62,7 +60,7 @@ func (c *ClientTests) TestReferralCustomerCreate() { ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.ReferralCustomer{}), reflect.TypeOf(user)) + assert.Equal(reflect.TypeOf(&ReferralCustomer{}), reflect.TypeOf(user)) assert.True(strings.HasPrefix(user.ID, "user_")) assert.Equal("Test Referral", user.Name) } @@ -72,7 +70,7 @@ func (c *ClientTests) TestReferralCustomerAll() { assert, require := c.Assert(), c.Require() referralCustomerCollection, err := client.ListReferralCustomers( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -81,13 +79,13 @@ func (c *ClientTests) TestReferralCustomerAll() { assert.LessOrEqual(len(referralCustomerCollection.ReferralCustomers), c.fixture.pageSize()) assert.NotNil(referralCustomerCollection.HasMore) for _, referralCustomer := range referralCustomerCollection.ReferralCustomers { - assert.Equal(reflect.TypeOf(&easypost.ReferralCustomer{}), reflect.TypeOf(referralCustomer)) + assert.Equal(reflect.TypeOf(&ReferralCustomer{}), reflect.TypeOf(referralCustomer)) } users, err := client.ListReferralCustomers(nil) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.ListReferralCustomersResult{}), reflect.TypeOf(users)) + assert.Equal(reflect.TypeOf(&ListReferralCustomersResult{}), reflect.TypeOf(users)) assert.True(len(users.ReferralCustomers) > 0) } @@ -111,10 +109,10 @@ func (c *ClientTests) TestReferralCustomerAddCreditCard() { referralAPIKey := c.ReferralAPIKey() - creditCard, err := client.AddReferralCustomerCreditCard(referralAPIKey, c.fixture.TestCreditCard(), easypost.PrimaryPaymentMethodPriority) + creditCard, err := client.AddReferralCustomerCreditCard(referralAPIKey, c.fixture.TestCreditCard(), PrimaryPaymentMethodPriority) require.NoError(err) - require.Equal(reflect.TypeOf(&easypost.PaymentMethodObject{}), reflect.TypeOf(creditCard)) + require.Equal(reflect.TypeOf(&PaymentMethodObject{}), reflect.TypeOf(creditCard)) assert.True(strings.HasSuffix(c.fixture.TestCreditCard().Number, creditCard.Last4)) } @@ -127,11 +125,11 @@ func (c *ClientTests) TestAddReferralCustomerCreditCardFromStripe() { _, err := client.AddReferralCustomerCreditCardFromStripe( referralAPIKey, c.fixture.BillingData().PaymentMethodID, - easypost.PrimaryPaymentMethodPriority, + PrimaryPaymentMethodPriority, ) require.Error(err) - var apiErr *easypost.APIError + var apiErr *APIError if errors.As(err, &apiErr) { assert.Equal("Stripe::PaymentMethod does not exist for the specified reference_id", apiErr.Message) } @@ -147,11 +145,11 @@ func (c *ClientTests) TestAddReferralCustomerBankAccountFromStripe() { referralAPIKey, c.fixture.BillingData().FinancialConnectionsID, c.fixture.BillingData().MandateData, - easypost.PrimaryPaymentMethodPriority, + PrimaryPaymentMethodPriority, ) require.Error(err) - var apiErr *easypost.APIError + var apiErr *APIError if errors.As(err, &apiErr) { assert.Equal("account_holder_name must be present when creating a Financial Connections payment method", apiErr.Message) } @@ -162,7 +160,7 @@ func (c *ClientTests) TestReferralCustomersGetNextPage() { assert, require := c.Assert(), c.Require() firstPage, err := client.ListReferralCustomers( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -180,7 +178,7 @@ func (c *ClientTests) TestReferralCustomersGetNextPage() { } }() if err != nil { - var endOfPaginationErr *easypost.EndOfPaginationError + var endOfPaginationErr *EndOfPaginationError if errors.As(err, &endOfPaginationErr) { assert.Equal(err.Error(), endOfPaginationErr.Error()) return diff --git a/tests/refund_test.go b/refund_test.go similarity index 86% rename from tests/refund_test.go rename to refund_test.go index ad7ddfa..d425683 100644 --- a/tests/refund_test.go +++ b/refund_test.go @@ -1,11 +1,9 @@ -package easypost_test +package easypost import ( "errors" "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestRefundCreate() { @@ -35,7 +33,7 @@ func (c *ClientTests) TestRefundAll() { assert, require := c.Assert(), c.Require() refunds, err := client.ListRefunds( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -46,7 +44,7 @@ func (c *ClientTests) TestRefundAll() { assert.LessOrEqual(len(refundsList), c.fixture.pageSize()) assert.NotNil(refunds.HasMore) for _, refund := range refundsList { - assert.Equal(reflect.TypeOf(&easypost.Refund{}), reflect.TypeOf(refund)) + assert.Equal(reflect.TypeOf(&Refund{}), reflect.TypeOf(refund)) } } @@ -55,7 +53,7 @@ func (c *ClientTests) TestRefundRetrieve() { assert, require := c.Assert(), c.Require() refunds, err := client.ListRefunds( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -64,7 +62,7 @@ func (c *ClientTests) TestRefundRetrieve() { retrievedRefund, err := client.GetRefund(refunds.Refunds[0].ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Refund{}), reflect.TypeOf(retrievedRefund)) + assert.Equal(reflect.TypeOf(&Refund{}), reflect.TypeOf(retrievedRefund)) assert.Equal(refunds.Refunds[0].ID, retrievedRefund.ID) } @@ -73,7 +71,7 @@ func (c *ClientTests) TestRefundsGetNextPage() { assert, require := c.Assert(), c.Require() firstPage, err := client.ListRefunds( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -91,7 +89,7 @@ func (c *ClientTests) TestRefundsGetNextPage() { } }() if err != nil { - var endOfPaginationErr *easypost.EndOfPaginationError + var endOfPaginationErr *EndOfPaginationError if errors.As(err, &endOfPaginationErr) { assert.Equal(err.Error(), endOfPaginationErr.Error()) return diff --git a/tests/report_test.go b/report_test.go similarity index 85% rename from tests/report_test.go rename to report_test.go index bd5f540..0e5b452 100644 --- a/tests/report_test.go +++ b/report_test.go @@ -1,11 +1,9 @@ -package easypost_test +package easypost import ( "errors" "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestReportCreate() { @@ -14,14 +12,14 @@ func (c *ClientTests) TestReportCreate() { report, err := client.CreateReport( c.fixture.ReportType(), - &easypost.Report{ + &Report{ StartDate: c.fixture.ReportDate(), EndDate: c.fixture.ReportDate(), }, ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Report{}), reflect.TypeOf(report)) + assert.Equal(reflect.TypeOf(&Report{}), reflect.TypeOf(report)) assert.True(strings.HasPrefix(report.ID, "shprep_")) } @@ -31,7 +29,7 @@ func (c *ClientTests) TestReportCustomColumnsCreate() { report, err := client.CreateReport( c.fixture.ReportType(), - &easypost.Report{ + &Report{ StartDate: c.fixture.ReportDate(), EndDate: c.fixture.ReportDate(), Columns: []string{"usps_zone"}, @@ -44,7 +42,7 @@ func (c *ClientTests) TestReportCustomColumnsCreate() { // There's unfortunately no way to check if the columns were included in the final report without parsing the CSV, // so we assume, if we haven't gotten an error by this point, we've made the API calls correctly // any failure at this point is a server-side issue - assert.Equal(reflect.TypeOf(&easypost.Report{}), reflect.TypeOf(report)) + assert.Equal(reflect.TypeOf(&Report{}), reflect.TypeOf(report)) } func (c *ClientTests) TestReportCustomAdditionalColumnsCreate() { @@ -53,7 +51,7 @@ func (c *ClientTests) TestReportCustomAdditionalColumnsCreate() { report, err := client.CreateReport( c.fixture.ReportType(), - &easypost.Report{ + &Report{ StartDate: c.fixture.ReportDate(), EndDate: c.fixture.ReportDate(), AdditionalColumns: []string{"from_name", "from_company"}, @@ -66,7 +64,7 @@ func (c *ClientTests) TestReportCustomAdditionalColumnsCreate() { // There's unfortunately no way to check if the columns were included in the final report without parsing the CSV, // so we assume, if we haven't gotten an error by this point, we've made the API calls correctly // any failure at this point is a server-side issue - assert.Equal(reflect.TypeOf(&easypost.Report{}), reflect.TypeOf(report)) + assert.Equal(reflect.TypeOf(&Report{}), reflect.TypeOf(report)) } func (c *ClientTests) TestReportRetrieve() { @@ -75,7 +73,7 @@ func (c *ClientTests) TestReportRetrieve() { report, err := client.CreateReport( c.fixture.ReportType(), - &easypost.Report{ + &Report{ StartDate: c.fixture.ReportDate(), EndDate: c.fixture.ReportDate(), }, @@ -85,7 +83,7 @@ func (c *ClientTests) TestReportRetrieve() { retrievedReport, err := client.GetReport(c.fixture.ReportType(), report.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Report{}), reflect.TypeOf(retrievedReport)) + assert.Equal(reflect.TypeOf(&Report{}), reflect.TypeOf(retrievedReport)) assert.Equal(report.StartDate, retrievedReport.StartDate) assert.Equal(report.EndDate, retrievedReport.EndDate) } @@ -96,7 +94,7 @@ func (c *ClientTests) TestReportAll() { reports, err := client.ListReports( c.fixture.ReportType(), - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -107,7 +105,7 @@ func (c *ClientTests) TestReportAll() { assert.LessOrEqual(len(reportsList), c.fixture.pageSize()) assert.NotNil(reports.HasMore) for _, report := range reportsList { - assert.Equal(reflect.TypeOf(&easypost.Report{}), reflect.TypeOf(report)) + assert.Equal(reflect.TypeOf(&Report{}), reflect.TypeOf(report)) } } @@ -117,7 +115,7 @@ func (c *ClientTests) TestReportsGetNextPage() { firstPage, err := client.ListReports( c.fixture.ReportType(), - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -135,7 +133,7 @@ func (c *ClientTests) TestReportsGetNextPage() { } }() if err != nil { - var endOfPaginationErr *easypost.EndOfPaginationError + var endOfPaginationErr *EndOfPaginationError if errors.As(err, &endOfPaginationErr) { assert.Equal(err.Error(), endOfPaginationErr.Error()) return diff --git a/tests/scan_form_test.go b/scan_form_test.go similarity index 82% rename from tests/scan_form_test.go rename to scan_form_test.go index c815cab..e3eb2a0 100644 --- a/tests/scan_form_test.go +++ b/scan_form_test.go @@ -1,11 +1,9 @@ -package easypost_test +package easypost import ( "errors" "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestScanFormCreate() { @@ -18,7 +16,7 @@ func (c *ClientTests) TestScanFormCreate() { scanform, err := client.CreateScanForm(shipment.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.ScanForm{}), reflect.TypeOf(scanform)) + assert.Equal(reflect.TypeOf(&ScanForm{}), reflect.TypeOf(scanform)) assert.True(strings.HasPrefix(scanform.ID, "sf_")) } @@ -35,7 +33,7 @@ func (c *ClientTests) TestScanFormRetrieve() { retrievedScanform, err := client.GetScanForm(scanform.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.ScanForm{}), reflect.TypeOf(retrievedScanform)) + assert.Equal(reflect.TypeOf(&ScanForm{}), reflect.TypeOf(retrievedScanform)) assert.Equal(scanform, retrievedScanform) } @@ -44,7 +42,7 @@ func (c *ClientTests) TestScanFormAll() { assert, require := c.Assert(), c.Require() scanforms, err := client.ListScanForms( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -55,7 +53,7 @@ func (c *ClientTests) TestScanFormAll() { assert.LessOrEqual(len(scanformsList), c.fixture.pageSize()) assert.NotNil(scanforms.HasMore) for _, scanform := range scanformsList { - assert.Equal(reflect.TypeOf(&easypost.ScanForm{}), reflect.TypeOf(scanform)) + assert.Equal(reflect.TypeOf(&ScanForm{}), reflect.TypeOf(scanform)) } } @@ -64,7 +62,7 @@ func (c *ClientTests) TestScanFormsGetNextPage() { assert, require := c.Assert(), c.Require() firstPage, err := client.ListScanForms( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -82,7 +80,7 @@ func (c *ClientTests) TestScanFormsGetNextPage() { } }() if err != nil { - var endOfPaginationErr *easypost.EndOfPaginationError + var endOfPaginationErr *EndOfPaginationError if errors.As(err, &endOfPaginationErr) { assert.Equal(err.Error(), endOfPaginationErr.Error()) return diff --git a/tests/shipment_test.go b/shipment_test.go similarity index 90% rename from tests/shipment_test.go rename to shipment_test.go index 1f01760..1220293 100644 --- a/tests/shipment_test.go +++ b/shipment_test.go @@ -1,11 +1,9 @@ -package easypost_test +package easypost import ( "errors" "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestShipmentCreate() { @@ -15,7 +13,7 @@ func (c *ClientTests) TestShipmentCreate() { shipment, err := client.CreateShipment(c.fixture.FullShipment()) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Shipment{}), reflect.TypeOf(shipment)) + assert.Equal(reflect.TypeOf(&Shipment{}), reflect.TypeOf(shipment)) assert.True(strings.HasPrefix(shipment.ID, "shp_")) assert.NotNil(shipment.Rates) assert.Equal("PNG", shipment.Options.LabelFormat) @@ -33,7 +31,7 @@ func (c *ClientTests) TestShipmentRetrieve() { retrievedShipment, err := client.GetShipment(shipment.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Shipment{}), reflect.TypeOf(retrievedShipment)) + assert.Equal(reflect.TypeOf(&Shipment{}), reflect.TypeOf(retrievedShipment)) assert.Equal(shipment, retrievedShipment) } @@ -42,7 +40,7 @@ func (c *ClientTests) TestShipmentAll() { assert, require := c.Assert(), c.Require() shipments, err := client.ListShipments( - &easypost.ListShipmentsOptions{ + &ListShipmentsOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -53,7 +51,7 @@ func (c *ClientTests) TestShipmentAll() { assert.LessOrEqual(len(shipmentsList), c.fixture.pageSize()) assert.NotNil(shipments.HasMore) for _, shipment := range shipmentsList { - assert.Equal(reflect.TypeOf(&easypost.Shipment{}), reflect.TypeOf(shipment)) + assert.Equal(reflect.TypeOf(&Shipment{}), reflect.TypeOf(shipment)) } } @@ -83,9 +81,9 @@ func (c *ClientTests) TestShipmentRegenerateRates() { rates, err := client.RerateShipment(shipment.ID) require.NoError(err) - assert.Equal(reflect.TypeOf([]*easypost.Rate{}), reflect.TypeOf(rates)) + assert.Equal(reflect.TypeOf([]*Rate{}), reflect.TypeOf(rates)) for _, rate := range rates { - assert.Equal(reflect.TypeOf(&easypost.Rate{}), reflect.TypeOf(rate)) + assert.Equal(reflect.TypeOf(&Rate{}), reflect.TypeOf(rate)) } } @@ -167,13 +165,13 @@ func (c *ClientTests) TestShipmentCreateEmptyObjects() { shipmentData.Options = nil shipmentData.TaxIdentifiers = nil shipmentData.Reference = "" - shipmentData.CustomsInfo = &easypost.CustomsInfo{} - shipmentData.CustomsInfo.CustomsItems = []*easypost.CustomsItem{} + shipmentData.CustomsInfo = &CustomsInfo{} + shipmentData.CustomsInfo.CustomsItems = []*CustomsItem{} shipment, err := client.CreateShipment(shipmentData) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Shipment{}), reflect.TypeOf(shipment)) + assert.Equal(reflect.TypeOf(&Shipment{}), reflect.TypeOf(shipment)) assert.True(strings.HasPrefix(shipment.ID, "shp_")) assert.NotNil(shipment.Options) // The EasyPost API populates some default values here assert.Nil(shipment.CustomsInfo) @@ -186,12 +184,12 @@ func (c *ClientTests) TestShipmentCreateTaxIdentifier() { assert, require := c.Assert(), c.Require() shipmentData := c.fixture.BasicShipment() - shipmentData.TaxIdentifiers = []*easypost.TaxIdentifier{c.fixture.TaxIdentifier()} + shipmentData.TaxIdentifiers = []*TaxIdentifier{c.fixture.TaxIdentifier()} shipment, err := client.CreateShipment(shipmentData) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Shipment{}), reflect.TypeOf(shipment)) + assert.Equal(reflect.TypeOf(&Shipment{}), reflect.TypeOf(shipment)) assert.True(strings.HasPrefix(shipment.ID, "shp_")) assert.Equal("IOSS", shipment.TaxIdentifiers[0].TaxIdType) } @@ -208,15 +206,15 @@ func (c *ClientTests) TestShipmentCreateWithIds() { require.NoError(err) shipment, err := client.CreateShipment( - &easypost.Shipment{ - FromAddress: &easypost.Address{ID: fromAddress.ID}, - ToAddress: &easypost.Address{ID: toAddress.ID}, - Parcel: &easypost.Parcel{ID: parcel.ID}, + &Shipment{ + FromAddress: &Address{ID: fromAddress.ID}, + ToAddress: &Address{ID: toAddress.ID}, + Parcel: &Parcel{ID: parcel.ID}, }, ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Shipment{}), reflect.TypeOf(shipment)) + assert.Equal(reflect.TypeOf(&Shipment{}), reflect.TypeOf(shipment)) assert.True(strings.HasPrefix(shipment.ID, "shp_")) assert.True(strings.HasPrefix(shipment.FromAddress.ID, "adr_")) assert.True(strings.HasPrefix(shipment.ToAddress.ID, "adr_")) @@ -323,7 +321,7 @@ func (c *ClientTests) TestShipmentsGetNextPage() { assert, require := c.Assert(), c.Require() firstPage, err := client.ListShipments( - &easypost.ListShipmentsOptions{ + &ListShipmentsOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -341,7 +339,7 @@ func (c *ClientTests) TestShipmentsGetNextPage() { } }() if err != nil { - var endOfPaginationErr *easypost.EndOfPaginationError + var endOfPaginationErr *EndOfPaginationError if errors.As(err, &endOfPaginationErr) { assert.Equal(err.Error(), endOfPaginationErr.Error()) return @@ -395,7 +393,7 @@ func (c *ClientTests) TestCreateAndBuyLumaShipment() { shipmentData := c.fixture.OneCallBuyShipment() shipmentData.Service = "" - lumaRequest := easypost.LumaRequest{ + lumaRequest := LumaRequest{ Shipment: *shipmentData, RulesetName: c.fixture.LumaRulesetName(), PlannedShipDate: c.fixture.LumaPlannedShipDate(), @@ -414,7 +412,7 @@ func (c *ClientTests) TestBuyLumaShipment() { shipment, err := client.CreateShipment(c.fixture.BasicShipment()) require.NoError(err) - lumaRequest := easypost.LumaRequest{ + lumaRequest := LumaRequest{ RulesetName: c.fixture.LumaRulesetName(), PlannedShipDate: c.fixture.LumaPlannedShipDate(), } diff --git a/tests/smart_rate_test.go b/smart_rate_test.go similarity index 90% rename from tests/smart_rate_test.go rename to smart_rate_test.go index c0997d8..a2ca336 100644 --- a/tests/smart_rate_test.go +++ b/smart_rate_test.go @@ -1,8 +1,4 @@ -package easypost_test - -import ( - "github.com/EasyPost/easypost-go/v5" -) +package easypost func (c *ClientTests) TestEstimateDeliveryDateForZipPair() { client := c.TestClient() @@ -10,7 +6,7 @@ func (c *ClientTests) TestEstimateDeliveryDateForZipPair() { carrier := c.fixture.USPS() - params := &easypost.EstimateDeliveryDateForZipPairParams{ + params := &EstimateDeliveryDateForZipPairParams{ FromZip: c.fixture.CaAddress1().Zip, ToZip: c.fixture.CaAddress2().Zip, Carriers: []string{carrier}, @@ -37,7 +33,7 @@ func (c *ClientTests) TestRecommendShipDateForZipPair() { carrier := c.fixture.USPS() - params := &easypost.RecommendShipDateForZipPairParams{ + params := &RecommendShipDateForZipPairParams{ FromZip: c.fixture.CaAddress1().Zip, ToZip: c.fixture.CaAddress2().Zip, Carriers: []string{carrier}, diff --git a/tests/tracker_test.go b/tracker_test.go similarity index 79% rename from tests/tracker_test.go rename to tracker_test.go index 0b4a75a..eae9347 100644 --- a/tests/tracker_test.go +++ b/tracker_test.go @@ -1,11 +1,9 @@ -package easypost_test +package easypost import ( "errors" "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestTrackerCreate() { @@ -13,13 +11,13 @@ func (c *ClientTests) TestTrackerCreate() { assert, require := c.Assert(), c.Require() tracker, err := client.CreateTracker( - &easypost.CreateTrackerOptions{ + &CreateTrackerOptions{ TrackingCode: "EZ1000000001", }, ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Tracker{}), reflect.TypeOf(tracker)) + assert.Equal(reflect.TypeOf(&Tracker{}), reflect.TypeOf(tracker)) assert.True(strings.HasPrefix(tracker.ID, "trk_")) assert.Equal("pre_transit", tracker.Status) } @@ -29,7 +27,7 @@ func (c *ClientTests) TestTrackerRetrieve() { assert, require := c.Assert(), c.Require() tracker, err := client.CreateTracker( - &easypost.CreateTrackerOptions{ + &CreateTrackerOptions{ TrackingCode: "EZ1000000001", }, ) @@ -39,7 +37,7 @@ func (c *ClientTests) TestTrackerRetrieve() { retrievedTracker, err := client.GetTracker(tracker.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Tracker{}), reflect.TypeOf(retrievedTracker)) + assert.Equal(reflect.TypeOf(&Tracker{}), reflect.TypeOf(retrievedTracker)) assert.Equal(tracker.ID, retrievedTracker.ID) } @@ -48,7 +46,7 @@ func (c *ClientTests) TestTrackerAll() { assert, require := c.Assert(), c.Require() trackers, err := client.ListTrackers( - &easypost.ListTrackersOptions{ + &ListTrackersOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -59,7 +57,7 @@ func (c *ClientTests) TestTrackerAll() { assert.LessOrEqual(len(trackersList), c.fixture.pageSize()) assert.NotNil(trackers.HasMore) for _, tracker := range trackersList { - assert.Equal(reflect.TypeOf(&easypost.Tracker{}), reflect.TypeOf(tracker)) + assert.Equal(reflect.TypeOf(&Tracker{}), reflect.TypeOf(tracker)) } } @@ -68,7 +66,7 @@ func (c *ClientTests) TestTrackersGetNextPage() { assert, require := c.Assert(), c.Require() firstPage, err := client.ListTrackers( - &easypost.ListTrackersOptions{ + &ListTrackersOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -86,7 +84,7 @@ func (c *ClientTests) TestTrackersGetNextPage() { } }() if err != nil { - var endOfPaginationErr *easypost.EndOfPaginationError + var endOfPaginationErr *EndOfPaginationError if errors.As(err, &endOfPaginationErr) { assert.Equal(err.Error(), endOfPaginationErr.Error()) return @@ -100,14 +98,14 @@ func (c *ClientTests) TestTrackerRetrieveBatch() { assert, require := c.Assert(), c.Require() tracker, err := client.CreateTracker( - &easypost.CreateTrackerOptions{ + &CreateTrackerOptions{ TrackingCode: "EZ1000000001", }, ) require.NoError(err) trackers, err := client.RetrieveTrackerBatch( - &easypost.ListTrackersOptions{ + &ListTrackersOptions{ TrackingCodes: []string{tracker.TrackingCode}, }, ) @@ -116,6 +114,6 @@ func (c *ClientTests) TestTrackerRetrieveBatch() { trackersList := trackers.Trackers for _, tracker := range trackersList { - assert.Equal(reflect.TypeOf(&easypost.Tracker{}), reflect.TypeOf(tracker)) + assert.Equal(reflect.TypeOf(&Tracker{}), reflect.TypeOf(tracker)) } } diff --git a/tests/user_test.go b/user_test.go similarity index 82% rename from tests/user_test.go rename to user_test.go index 0eaceee..710cf6e 100644 --- a/tests/user_test.go +++ b/user_test.go @@ -1,11 +1,9 @@ -package easypost_test +package easypost import ( "errors" "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestUserCreate() { @@ -15,13 +13,13 @@ func (c *ClientTests) TestUserCreate() { userName := "Test User" user, err := client.CreateUser( - &easypost.UserOptions{ + &UserOptions{ Name: &userName, }, ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.User{}), reflect.TypeOf(user)) + assert.Equal(reflect.TypeOf(&User{}), reflect.TypeOf(user)) assert.True(strings.HasPrefix(user.ID, "user_")) assert.Equal("Test User", user.Name) } @@ -36,7 +34,7 @@ func (c *ClientTests) TestUserRetrieve() { retrievedUser, err := client.GetUser(authenticatedUser.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.User{}), reflect.TypeOf(retrievedUser)) + assert.Equal(reflect.TypeOf(&User{}), reflect.TypeOf(retrievedUser)) assert.True(strings.HasPrefix(retrievedUser.ID, "user_")) } @@ -47,7 +45,7 @@ func (c *ClientTests) TestUserRetrieveMe() { user, err := client.RetrieveMe() require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.User{}), reflect.TypeOf(user)) + assert.Equal(reflect.TypeOf(&User{}), reflect.TypeOf(user)) assert.True(strings.HasPrefix(user.ID, "user_")) } @@ -56,7 +54,7 @@ func (c *ClientTests) TestUserAllChildUsers() { assert, require := c.Assert(), c.Require() childUsers, err := client.ListChildUsers( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -65,7 +63,7 @@ func (c *ClientTests) TestUserAllChildUsers() { assert.LessOrEqual(len(childUsers.Children), c.fixture.pageSize()) assert.NotNil(childUsers.HasMore) for _, user := range childUsers.Children { - assert.Equal(reflect.TypeOf(&easypost.User{}), reflect.TypeOf(user)) + assert.Equal(reflect.TypeOf(&User{}), reflect.TypeOf(user)) } } @@ -74,7 +72,7 @@ func (c *ClientTests) TestUserGetNextChildUserPage() { assert, require := c.Assert(), c.Require() firstPage, err := client.ListChildUsers( - &easypost.ListOptions{ + &ListOptions{ PageSize: c.fixture.pageSize(), }, ) @@ -92,7 +90,7 @@ func (c *ClientTests) TestUserGetNextChildUserPage() { } }() if err != nil { - var endOfPaginationErr *easypost.EndOfPaginationError + var endOfPaginationErr *EndOfPaginationError if errors.As(err, &endOfPaginationErr) { assert.Equal(err.Error(), endOfPaginationErr.Error()) return @@ -111,14 +109,14 @@ func (c *ClientTests) TestUserUpdate() { test_name := "Test User" updatedUser, err := client.UpdateUser( - &easypost.UserOptions{ + &UserOptions{ ID: user.ID, Name: &test_name, }, ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.User{}), reflect.TypeOf(updatedUser)) + assert.Equal(reflect.TypeOf(&User{}), reflect.TypeOf(updatedUser)) assert.True(strings.HasPrefix(updatedUser.ID, "user_")) assert.Equal(test_name, updatedUser.Name) } @@ -140,7 +138,7 @@ func (c *ClientTests) TestUserUpdateBrand() { ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Brand{}), reflect.TypeOf(brand)) + assert.Equal(reflect.TypeOf(&Brand{}), reflect.TypeOf(brand)) assert.True(strings.HasPrefix(brand.ID, "brd_")) assert.Equal(color, brand.Color) } @@ -152,7 +150,7 @@ func (c *ClientTests) TestUserDelete() { userName := "Test User" user, err := client.CreateUser( - &easypost.UserOptions{ + &UserOptions{ Name: &userName, }, ) diff --git a/tests/util_test.go b/util_test.go similarity index 56% rename from tests/util_test.go rename to util_test.go index d7c5c48..024cdb9 100644 --- a/tests/util_test.go +++ b/util_test.go @@ -1,19 +1,15 @@ -package easypost_test - -import ( - "github.com/EasyPost/easypost-go/v5" -) +package easypost func (c *ClientTests) TestStringPointer() { assert := c.Assert() - stringPointer := *easypost.StringPtr("test") + stringPointer := *StringPtr("test") assert.Equal(stringPointer, "test") } func (c *ClientTests) TestBoolPointer() { assert := c.Assert() - boolPointer := *easypost.BoolPtr(true) + boolPointer := *BoolPtr(true) assert.Equal(boolPointer, true) } diff --git a/tests/webhook_test.go b/webhook_test.go similarity index 80% rename from tests/webhook_test.go rename to webhook_test.go index 3efaab1..b745090 100644 --- a/tests/webhook_test.go +++ b/webhook_test.go @@ -1,10 +1,8 @@ -package easypost_test +package easypost import ( "reflect" "strings" - - "github.com/EasyPost/easypost-go/v5" ) func (c *ClientTests) TestWebhookCreate() { @@ -12,15 +10,15 @@ func (c *ClientTests) TestWebhookCreate() { assert, require := c.Assert(), c.Require() webhook, err := client.CreateWebhook( - &easypost.CreateUpdateWebhookOptions{ - URL: c.fixture.WebhookUrl(), + &CreateUpdateWebhookOptions{ + URL: c.fixture.WebhookUrl(), WebhookSecret: c.fixture.WebhookSecret(), CustomHeaders: c.fixture.WebhookCustomHeaders(), }, ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Webhook{}), reflect.TypeOf(webhook)) + assert.Equal(reflect.TypeOf(&Webhook{}), reflect.TypeOf(webhook)) assert.True(strings.HasPrefix(webhook.ID, "hook_")) assert.Equal(c.fixture.WebhookUrl(), webhook.URL) assert.Equal(c.fixture.WebhookCustomHeaders(), webhook.CustomHeaders) @@ -36,7 +34,7 @@ func (c *ClientTests) TestWebhookRetrieve() { assert, require := c.Assert(), c.Require() webhook, err := client.CreateWebhook( - &easypost.CreateUpdateWebhookOptions{ + &CreateUpdateWebhookOptions{ URL: c.fixture.WebhookUrl(), }, ) @@ -45,7 +43,7 @@ func (c *ClientTests) TestWebhookRetrieve() { retrievedWebhook, err := client.GetWebhook(webhook.ID) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Webhook{}), reflect.TypeOf(retrievedWebhook)) + assert.Equal(reflect.TypeOf(&Webhook{}), reflect.TypeOf(retrievedWebhook)) assert.Equal(webhook, retrievedWebhook) err = client.DeleteWebhook(retrievedWebhook.ID) // we are deleting the webhook here, so we don't keep sending events to a dead webhook. @@ -63,7 +61,7 @@ func (c *ClientTests) TestWebhookAll() { assert.LessOrEqual(len(webhooks), c.fixture.pageSize()) for _, webhook := range webhooks { - assert.Equal(reflect.TypeOf(&easypost.Webhook{}), reflect.TypeOf(webhook)) + assert.Equal(reflect.TypeOf(&Webhook{}), reflect.TypeOf(webhook)) } } @@ -72,13 +70,13 @@ func (c *ClientTests) TestWebhookDelete() { assert, require := c.Assert(), c.Require() webhook, err := client.CreateWebhook( - &easypost.CreateUpdateWebhookOptions{ + &CreateUpdateWebhookOptions{ URL: c.fixture.WebhookUrl(), }, ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Webhook{}), reflect.TypeOf(webhook)) + assert.Equal(reflect.TypeOf(&Webhook{}), reflect.TypeOf(webhook)) assert.True(strings.HasPrefix(webhook.ID, "hook_")) assert.Equal(c.fixture.WebhookUrl(), webhook.URL) @@ -94,7 +92,7 @@ func (c *ClientTests) TestWebhookUpdate() { assert, require := c.Assert(), c.Require() webhook, err := client.CreateWebhook( - &easypost.CreateUpdateWebhookOptions{ + &CreateUpdateWebhookOptions{ URL: c.fixture.WebhookUrl(), }, ) @@ -102,7 +100,7 @@ func (c *ClientTests) TestWebhookUpdate() { updatedWebhook, err := client.UpdateWebhook( webhook.ID, - &easypost.CreateUpdateWebhookOptions{ + &CreateUpdateWebhookOptions{ WebhookSecret: c.fixture.WebhookSecret(), CustomHeaders: c.fixture.WebhookCustomHeaders(), }, @@ -110,7 +108,7 @@ func (c *ClientTests) TestWebhookUpdate() { require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Webhook{}), reflect.TypeOf(updatedWebhook)) + assert.Equal(reflect.TypeOf(&Webhook{}), reflect.TypeOf(updatedWebhook)) assert.Equal(c.fixture.WebhookCustomHeaders(), updatedWebhook.CustomHeaders) err = client.DeleteWebhook(updatedWebhook.ID) @@ -122,14 +120,14 @@ func (c *ClientTests) TestWebhookCreateWithSecret() { assert, require := c.Assert(), c.Require() webhook, err := client.CreateWebhook( - &easypost.CreateUpdateWebhookOptions{ + &CreateUpdateWebhookOptions{ URL: c.fixture.WebhookUrl(), WebhookSecret: c.fixture.WebhookSecret(), }, ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Webhook{}), reflect.TypeOf(webhook)) + assert.Equal(reflect.TypeOf(&Webhook{}), reflect.TypeOf(webhook)) assert.True(strings.HasPrefix(webhook.ID, "hook_")) assert.Equal(c.fixture.WebhookUrl(), webhook.URL) @@ -142,20 +140,20 @@ func (c *ClientTests) TestWebhookUpdateWithSecret() { assert, require := c.Assert(), c.Require() webhook, err := client.CreateWebhook( - &easypost.CreateUpdateWebhookOptions{ + &CreateUpdateWebhookOptions{ URL: c.fixture.WebhookUrl(), }, ) require.NoError(err) updatedWebhook, err := client.UpdateWebhook(webhook.ID, - &easypost.CreateUpdateWebhookOptions{ + &CreateUpdateWebhookOptions{ WebhookSecret: c.fixture.WebhookSecret(), }, ) require.NoError(err) - assert.Equal(reflect.TypeOf(&easypost.Webhook{}), reflect.TypeOf(updatedWebhook)) + assert.Equal(reflect.TypeOf(&Webhook{}), reflect.TypeOf(updatedWebhook)) err = client.DeleteWebhook(updatedWebhook.ID) require.NoError(err) @@ -173,7 +171,7 @@ func (c *ClientTests) TestValidateWebhook() { require.NoError(err) assert.Equal(webhookBody.Description, "tracker.updated") - assert.Equal(webhookBody.Result.(*easypost.Tracker).Weight, 614.4) // Ensure we convert floats properly + assert.Equal(webhookBody.Result.(*Tracker).Weight, 614.4) // Ensure we convert floats properly } func (c *ClientTests) TestValidateWebhookInvalidSecret() {