-
Notifications
You must be signed in to change notification settings - Fork 0
/
rates_test.go
79 lines (76 loc) · 1.74 KB
/
rates_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package pakmail
import (
"reflect"
"testing"
"github.com/gustavotero7/pakmail-go/models"
)
func TestRate(t *testing.T) {
type args struct {
req models.RateRequest
}
tests := []struct {
name string
args args
want *models.RateResponse
wantErr bool
}{
{
name: "OK",
args: args{
req: models.RateRequest{
OrderTotalAmount: 60,
OriginDirection: models.Direction{
FullName: "Leopold stoch",
City: "Ciudad Mexiko",
Phone: "23232323",
StateCode: "DF",
PostalCode: "11550",
CountryCode: "MX",
Direction1: "Av siempre viva",
},
DestinationDirection: models.Direction{
FullName: "Stan Marsh",
City: "Ciudad Mexiko",
Phone: "23232323",
StateCode: "DF",
PostalCode: "01210",
CountryCode: "MX",
Direction1: "Av siempre viva",
},
Shipment: models.Shipment{
ShipmentType: "Package",
InsuredValue: 5000,
InsuredValueCurrency: "MXN",
Content: "Description",
Parcels: []models.Parcel{
models.Parcel{
Quantity: 1,
Weight: 3,
WeightUnit: models.WeightUnitKG,
Length: 10,
Height: 20,
Width: 30,
DimensionUnit: models.DimensionUnitCM,
},
},
},
},
},
want: nil,
wantErr: false,
},
}
APIKey = ""
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := Rate(tt.args.req)
if (err != nil) != tt.wantErr {
t.Errorf("Rate() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Rate() = %v, want %v", got, tt.want)
}
})
}
}