Update January 30, 2025 (#142)

This commit is contained in:
Kirill
2025-03-02 01:25:37 +03:00
committed by GitHub
parent 739f672caf
commit 4831ad70d6
2 changed files with 194 additions and 0 deletions

View File

@@ -1208,3 +1208,118 @@ func TestGetDraftTimeslots(t *testing.T) {
}
}
}
func TestCancelSuppyOrder(t *testing.T) {
t.Parallel()
tests := []struct {
statusCode int
headers map[string]string
params *CancelSuppyOrderParams
response string
}{
// Test Ok
{
http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
&CancelSuppyOrderParams{
OrderId: 11,
},
`{
"operation_id": "string"
}`,
},
// Test No Client-Id or Api-Key
{
http.StatusUnauthorized,
map[string]string{},
&CancelSuppyOrderParams{},
`{
"code": 16,
"message": "Client-Id and Api-Key headers are required"
}`,
},
}
for _, test := range tests {
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
ctx, _ := context.WithTimeout(context.Background(), testTimeout)
resp, err := c.FBO().CancelSuppyOrder(ctx, test.params)
if err != nil {
t.Error(err)
continue
}
compareJsonResponse(t, test.response, &CancelSuppyOrderResponse{})
if resp.StatusCode != test.statusCode {
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
}
}
}
func TestStatusCancelledSupplyOrder(t *testing.T) {
t.Parallel()
tests := []struct {
statusCode int
headers map[string]string
params *StatusCancelledSupplyOrderParams
response string
}{
// Test Ok
{
http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
&StatusCancelledSupplyOrderParams{
OperationId: "123",
},
`{
"error_reasons": [
"INVALID_ORDER_STATE"
],
"result": {
"is_order_cancelled": true,
"supplies": [
{
"error_reasons": [
"INVALID_SUPPLY_STATE"
],
"is_supply_cancelled": true,
"supply_id": 0
}
]
},
"status": "SUCCESS"
}`,
},
// Test No Client-Id or Api-Key
{
http.StatusUnauthorized,
map[string]string{},
&StatusCancelledSupplyOrderParams{},
`{
"code": 16,
"message": "Client-Id and Api-Key headers are required"
}`,
},
}
for _, test := range tests {
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
ctx, _ := context.WithTimeout(context.Background(), testTimeout)
resp, err := c.FBO().StatusCancelledSupplyOrder(ctx, test.params)
if err != nil {
t.Error(err)
continue
}
compareJsonResponse(t, test.response, &StatusCancelledSupplyOrderResponse{})
if resp.StatusCode != test.statusCode {
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
}
}
}