add methods for packing orders and getting list of products

This commit is contained in:
diPhantxm
2023-03-14 20:35:28 +03:00
parent 86916b568b
commit 8c9fdac81c
5 changed files with 566 additions and 13 deletions

View File

@@ -262,3 +262,51 @@ func TestGetFBSShipmentsList(t *testing.T) {
}
}
}
func TestPackOrder(t *testing.T) {
tests := []struct {
statusCode int
headers map[string]string
params *PackOrderParams
response string
}{
{
http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
&PackOrderParams{
Packages: []PackOrderPackage{
{
Products: []PackOrderPackageProduct{
{
ProductId: 185479045,
Quantity: 1,
},
},
},
},
PostingNumber: "89491381-0072-1",
With: PackOrderWith{
AdditionalData: true,
},
},
`{
"result": [
"89491381-0072-1"
]
}`,
},
}
for _, test := range tests {
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
resp, err := c.PackOrder(test.params)
if err != nil {
t.Error(err)
}
if resp.StatusCode != test.statusCode {
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
}
}
}