diff options
Diffstat (limited to 'cost_test.go')
| -rw-r--r-- | cost_test.go | 66 |
1 files changed, 30 insertions, 36 deletions
diff --git a/cost_test.go b/cost_test.go index 15b2fe1..446440d 100644 --- a/cost_test.go +++ b/cost_test.go @@ -40,31 +40,33 @@ var printJobCostReqSample = printJobCostReq{ Express, } -var printJobCostSample = PrintJobCost{ - Addr: ShippingAddress{ - City: "Lübeck", - PostCode: "23552", - Street1: "Holstenstr. 40", - Phone: MustParsePhoneNumber("844-212-0689"), - State: "", - Country: "DE", - IsBusiness: false, - Name: ". .", - }, - SuggestedAddr: ShippingAddress{ - Country: "DE", - State: "", - PostCode: "23552", - City: "Lübeck", - Street1: "Holstenstraße 40", - Street2: "", +var printJobCostRespSample = printJobCostResp{ + AddressValidation: ShippingAddressValidation{ + Address: ShippingAddress{ + City: "Lübeck", + PostCode: "23552", + Street1: "Holstenstr. 40", + Phone: MustParsePhoneNumber("844-212-0689"), + State: "", + Country: "DE", + IsBusiness: false, + Name: ". .", + }, + Suggested: ShippingAddress{ + Country: "DE", + State: "", + PostCode: "23552", + City: "Lübeck", + Street1: "Holstenstraße 40", + Street2: "", + }, + Warnings: []ShippingAddressWarning{{ + "validation_warning", + "external", + "REPLACED", + "street1: Holstenstr. 40 -> Holstenstraße 40", + }}, }, - AddrWarnings: []ShippingAddressWarning{{ - "validation_warning", - "external", - "REPLACED", - "street1: Holstenstr. 40 -> Holstenstraße 40", - }}, Fees: []Fee{ { Currency: "USD", @@ -130,8 +132,8 @@ func TestMarshalPrintJobCostReq(t *testing.T) { requireMarshalJsonEq(t, printJobCostReqJson, printJobCostReqSample) } -func TestUnmarshalPrintJobCost(t *testing.T) { - requireUnmarshalJsonEq(t, printJobCostSample, printJobCostRespJson) +func TestUnmarshalPrintJobCostResp(t *testing.T) { + requireUnmarshalJsonEq(t, printJobCostRespSample, printJobCostRespJson) } func TestPrintJobCost(t *testing.T) { @@ -146,17 +148,9 @@ func TestPrintJobCost(t *testing.T) { Phone: MustParsePhoneNumber("844-212-0689"), } shiplvl := printJobCostReqSample.ShipOpt - cost, err := c.PrintJobCost(items, addr, shiplvl) + cost, av, err := c.PrintJobCost(items, addr, shiplvl) require.NoError(t, err) - require.Equal(t, "Lübeck", cost.Addr.City) - require.Equal(t, "23552", cost.Addr.PostCode) - require.Equal(t, "Holstenstr. 40", cost.Addr.Street1) - require.Equal(t, MustParsePhoneNumber("844-212-0689"), cost.Addr.Phone) - require.Empty(t, cost.Addr.State) - require.Equal(t, "DE", cost.Addr.Country) - require.False(t, cost.Addr.IsBusiness) - require.Equal(t, printJobCostSample.SuggestedAddr, cost.SuggestedAddr) - require.Equal(t, printJobCostSample.AddrWarnings, cost.AddrWarnings) + require.Equal(t, printJobCostRespSample.AddressValidation, av) requireCurrency(t, cost.Currency) for _, fee := range cost.Fees { requireCurrency(t, fee.Currency) |