extend tests, update readme

This commit is contained in:
diPhantxm
2023-03-15 02:00:16 +03:00
parent a082200b4f
commit 396f370174
11 changed files with 268 additions and 37 deletions

View File

@@ -14,6 +14,7 @@ func TestGetStocksInfo(t *testing.T) {
params *GetStocksInfoParams
response string
}{
// Test Ok
{
http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
@@ -51,27 +52,14 @@ func TestGetStocksInfo(t *testing.T) {
}
}`,
},
// Test No Client-Id or Api-Key
{
http.StatusBadRequest,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
&GetStocksInfoParams{
Limit: 100,
LastId: "",
Filter: GetStocksInfoFilter{
OfferId: "136834",
ProductId: 214887921,
Visibility: "ALL",
},
},
http.StatusUnauthorized,
map[string]string{},
&GetStocksInfoParams{},
`{
"code": 0,
"details": [
{
"typeUrl": "string",
"value": "string"
}
],
"message": "string"
"code": 16,
"message": "Client-Id and Api-Key headers are required"
}`,
},
}
@@ -97,6 +85,7 @@ func TestGetProductDetails(t *testing.T) {
params *GetProductDetailsParams
response string
}{
// Test Ok
{
http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
@@ -227,21 +216,14 @@ func TestGetProductDetails(t *testing.T) {
}
}`,
},
// Test No Client-Id or Api-Key
{
http.StatusBadRequest,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
&GetProductDetailsParams{
ProductId: 137208233,
},
http.StatusUnauthorized,
map[string]string{},
&GetProductDetailsParams{},
`{
"code": 0,
"details": [
{
"typeUrl": "string",
"value": "string"
}
],
"message": "string"
"code": 16,
"message": "Client-Id and Api-Key headers are required"
}`,
},
}
@@ -267,6 +249,7 @@ func TestUpdateStocks(t *testing.T) {
params *UpdateStocksParams
response string
}{
// Test Ok
{
http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
@@ -290,6 +273,16 @@ func TestUpdateStocks(t *testing.T) {
]
}`,
},
// Test No Client-Id or Api-Key
{
http.StatusUnauthorized,
map[string]string{},
&UpdateStocksParams{},
`{
"code": 16,
"message": "Client-Id and Api-Key headers are required"
}`,
},
}
for _, test := range tests {
@@ -313,6 +306,7 @@ func TestStocksInSellersWarehouse(t *testing.T) {
params *StocksInSellersWarehouseParams
response string
}{
// Test Ok
{
http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
@@ -332,6 +326,16 @@ func TestStocksInSellersWarehouse(t *testing.T) {
]
}`,
},
// Test No Client-Id or Api-Key
{
http.StatusUnauthorized,
map[string]string{},
&StocksInSellersWarehouseParams{},
`{
"code": 16,
"message": "Client-Id and Api-Key headers are required"
}`,
},
}
for _, test := range tests {
@@ -355,6 +359,7 @@ func TestUpdatePrices(t *testing.T) {
params *UpdatePricesParams
response string
}{
// Test Ok
{
http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
@@ -381,6 +386,16 @@ func TestUpdatePrices(t *testing.T) {
]
}`,
},
// Test No Client-Id or Api-Key
{
http.StatusUnauthorized,
map[string]string{},
&UpdatePricesParams{},
`{
"code": 16,
"message": "Client-Id and Api-Key headers are required"
}`,
},
}
for _, test := range tests {
@@ -404,6 +419,7 @@ func TestUpdateQuantityStockProducts(t *testing.T) {
params *UpdateQuantityStockProductsParams
response string
}{
// Test Ok
{
http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
@@ -429,6 +445,16 @@ func TestUpdateQuantityStockProducts(t *testing.T) {
]
}`,
},
// Test No Client-Id or Api-Key
{
http.StatusUnauthorized,
map[string]string{},
&UpdateQuantityStockProductsParams{},
`{
"code": 16,
"message": "Client-Id and Api-Key headers are required"
}`,
},
}
for _, test := range tests {
@@ -452,6 +478,7 @@ func TestCreateOrUpdateProduct(t *testing.T) {
params *CreateOrUpdateProductParams
response string
}{
// Test Ok
{
http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
@@ -533,6 +560,16 @@ func TestCreateOrUpdateProduct(t *testing.T) {
}
}`,
},
// Test No Client-Id or Api-Key
{
http.StatusUnauthorized,
map[string]string{},
&CreateOrUpdateProductParams{},
`{
"code": 16,
"message": "Client-Id and Api-Key headers are required"
}`,
},
}
for _, test := range tests {
@@ -556,6 +593,7 @@ func TestGetListOfProducts(t *testing.T) {
params *GetListOfProductsParams
response string
}{
// Test Ok
{
http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
@@ -581,6 +619,16 @@ func TestGetListOfProducts(t *testing.T) {
}
}`,
},
// Test No Client-Id or Api-Key
{
http.StatusUnauthorized,
map[string]string{},
&GetListOfProductsParams{},
`{
"code": 16,
"message": "Client-Id and Api-Key headers are required"
}`,
},
}
for _, test := range tests {