Update October 17, 2024 (#108)

This commit is contained in:
Kirill
2024-10-31 15:47:35 +03:00
committed by GitHub
parent 3430ead143
commit 1706575a34
4 changed files with 85 additions and 134 deletions

View File

@@ -2140,79 +2140,6 @@ func TestRemoveProductWithoutSKU(t *testing.T) {
}
}
func TestListGeoRestrictions(t *testing.T) {
t.Parallel()
tests := []struct {
statusCode int
headers map[string]string
params *ListGeoRestrictionsParams
response string
}{
// Test Ok
{
http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
&ListGeoRestrictionsParams{
Filter: ListGeoRestrictionsFilter{
OnlyVisible: true,
},
LastOrderNumber: 0,
Limit: 3,
},
`{
"restrictions": [
{
"id": "world",
"name": "Весь Мир",
"is_visible": true,
"order_number": 1
},
{
"id": "42fb1c32-0cfe-5c96-9fb5-7f8e8449f28c",
"name": "Все города РФ",
"is_visible": true,
"order_number": 2
},
{
"id": "moscow",
"name": "Москва",
"is_visible": true,
"order_number": 3
}
]
}`,
},
// Test No Client-Id or Api-Key
{
http.StatusUnauthorized,
map[string]string{},
&ListGeoRestrictionsParams{},
`{
"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.Products().ListGeoRestrictions(ctx, test.params)
if err != nil {
t.Error(err)
continue
}
compareJsonResponse(t, test.response, &ListGeoRestrictionsResponse{})
if resp.StatusCode != test.statusCode {
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
}
}
}
func TestUploadActivationCodes(t *testing.T) {
t.Parallel()