extend tests
This commit is contained in:
@@ -127,5 +127,11 @@ func TestGetStocksOnWarehouses(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if len(resp.Result.Rows) > int(test.params.Limit) {
|
||||
t.Errorf("Length of rows is bigger than limit")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,6 +347,10 @@ func TestPackOrder(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if len(resp.Result) != len(test.params.Packages) {
|
||||
t.Errorf("Length of packages in request and response are not equal")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,5 +424,16 @@ func TestValidateLabelingCodes(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if len(resp.Result.Products) != len(test.params.Products) {
|
||||
t.Errorf("Length of products in request and response are not equal")
|
||||
}
|
||||
if len(resp.Result.Products) > 0 {
|
||||
if resp.Result.Products[0].ProductId != test.params.Products[0].ProductId {
|
||||
t.Errorf("Product ids in request and response are not equal")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ozon
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
@@ -77,6 +78,20 @@ func TestGetStocksInfo(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if len(resp.Result.Items) > int(test.params.Limit) {
|
||||
t.Errorf("Amount of items in response cannot be bigger than limit")
|
||||
}
|
||||
if len(resp.Result.Items) > 0 {
|
||||
if resp.Result.Items[0].ProductId == 0 {
|
||||
t.Errorf("Product id cannot be 0")
|
||||
}
|
||||
if resp.Result.Items[0].OfferId == "" {
|
||||
t.Errorf("Offer id cannot be empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,6 +258,21 @@ func TestGetProductDetails(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if resp.Result.Id != test.params.ProductId {
|
||||
t.Errorf("Id of product in response is not equal product_id in request")
|
||||
}
|
||||
if resp.Result.OfferId == "" {
|
||||
t.Errorf("Offer id cannot be empty")
|
||||
}
|
||||
if resp.Result.CategoryId == 0 {
|
||||
t.Errorf("Category id cannot be 0")
|
||||
}
|
||||
if resp.Result.CurrencyCode == "" {
|
||||
t.Errorf("Currency code cannot be empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,6 +332,20 @@ func TestUpdateStocks(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if len(resp.Result) != len(test.params.Stocks) {
|
||||
t.Errorf("Length of stocks in request and response are not equal")
|
||||
}
|
||||
if len(resp.Result) > 0 {
|
||||
if resp.Result[0].OfferId != test.params.Stocks[0].OfferId {
|
||||
t.Errorf("Offer ids in request and response are not equal")
|
||||
}
|
||||
if resp.Result[0].ProductId != test.params.Stocks[0].ProductId {
|
||||
t.Errorf("Product ids in request and response are not equal")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,6 +401,17 @@ func TestStocksInSellersWarehouse(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if len(resp.Result) != len(test.params.FBSSKU) {
|
||||
t.Errorf("Length of skus in request and response must be equal")
|
||||
}
|
||||
if len(resp.Result) > 0 {
|
||||
if fmt.Sprint(resp.Result[0].FBSSKU) == test.params.FBSSKU[0] {
|
||||
t.Errorf("fbs sku in request and response are not equal")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,6 +474,17 @@ func TestUpdatePrices(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if len(resp.Result) != len(test.params.Prices) {
|
||||
t.Errorf("Length of prices in request and response are not equal")
|
||||
}
|
||||
if len(resp.Result) > 0 {
|
||||
if resp.Result[0].ProductId != test.params.Prices[0].ProductId {
|
||||
t.Errorf("Product ids in request and response are not equal")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -439,7 +505,7 @@ func TestUpdateQuantityStockProducts(t *testing.T) {
|
||||
Stocks: []UpdateQuantityStockProductsStock{
|
||||
{
|
||||
OfferId: "PH11042",
|
||||
ProductId: 313455276,
|
||||
ProductId: 118597312,
|
||||
Stock: 100,
|
||||
WarehouseId: 22142605386000,
|
||||
},
|
||||
@@ -480,6 +546,23 @@ func TestUpdateQuantityStockProducts(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if len(resp.Result) != len(test.params.Stocks) {
|
||||
t.Errorf("Length of stocks in request and response are not equal")
|
||||
}
|
||||
if len(resp.Result) > 0 {
|
||||
if resp.Result[0].Offerid != test.params.Stocks[0].OfferId {
|
||||
t.Errorf("Offer ids in request and response are not equal")
|
||||
}
|
||||
if resp.Result[0].ProductId != test.params.Stocks[0].ProductId {
|
||||
t.Errorf("Product ids in request and response are not equal")
|
||||
}
|
||||
if resp.Result[0].WarehouseId != test.params.Stocks[0].WarehouseId {
|
||||
t.Errorf("Warehouse ids in request and response are not equal")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -597,6 +680,12 @@ func TestCreateOrUpdateProduct(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if resp.Result.TaskId == 0 {
|
||||
t.Errorf("Task id cannot be 0")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -658,6 +747,23 @@ func TestGetListOfProducts(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if len(resp.Result.Items) != int(resp.Result.Total) {
|
||||
t.Errorf("Length of items is not equal total")
|
||||
}
|
||||
if resp.Result.Total > int32(test.params.Limit) {
|
||||
t.Errorf("Length of items is bigger than limit")
|
||||
}
|
||||
if len(resp.Result.Items) > 0 {
|
||||
if resp.Result.Items[0].OfferId == "" {
|
||||
t.Errorf("Offer id cannot be empty")
|
||||
}
|
||||
if resp.Result.Items[0].ProductId == 0 {
|
||||
t.Errorf("Product id cannot be 0")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -887,5 +993,16 @@ func TestGetProductsRatingBySKU(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if len(resp.Products) != len(test.params.SKUs) {
|
||||
t.Errorf("Length of products in response is not equal length of skus in request")
|
||||
}
|
||||
if len(resp.Products) > 0 {
|
||||
if resp.Products[0].SKU != test.params.SKUs[0] {
|
||||
t.Errorf("SKU in request and response are not equal")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,17 @@ func TestGetAvailablePromotions(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if len(resp.Result) > 0 {
|
||||
if resp.Result[0].Id == 0 {
|
||||
t.Errorf("Id cannot be 0")
|
||||
}
|
||||
if resp.Result[0].ActionType == "" {
|
||||
t.Errorf("Action type cannot be empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,5 +133,11 @@ func TestAddToPromotion(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if len(resp.Result.ProductIds) != len(test.params.Products) {
|
||||
t.Errorf("Length of products in response and request must be equal")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,14 @@ func TestGetCurrentRatingInfo(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if len(resp.Groups) > 0 {
|
||||
if len(resp.Groups[0].Items) == 0 {
|
||||
t.Errorf("Length of items in a group cannot be 0")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,5 +154,13 @@ func TestGetRatingInfoForPeriod(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if len(resp.Ratings) > 0 {
|
||||
if resp.Ratings[0].Rating == "" {
|
||||
t.Errorf("Rating system cannot be empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ type GetReportsListResponse struct {
|
||||
|
||||
// Method result
|
||||
Result struct {
|
||||
// Array with generated reports
|
||||
Reports []struct {
|
||||
// Unique report identifier
|
||||
Code string `json:"code"`
|
||||
|
||||
@@ -70,10 +72,11 @@ type GetReportsListResponse struct {
|
||||
// - `success`
|
||||
// - `failed`
|
||||
Status string `json:"status"`
|
||||
} `json:"result"`
|
||||
} `json:"reports"`
|
||||
|
||||
// Total number of reports
|
||||
Total int32 `json:"total"`
|
||||
} `json:"result"`
|
||||
}
|
||||
|
||||
// Returns the list of reports that have been generated before
|
||||
@@ -136,7 +139,7 @@ type GetReportDetailsResponse struct {
|
||||
|
||||
// Returns information about a created report by its identifier
|
||||
func (c Reports) GetReportDetails(params *GetReportDetailsParams) (*GetReportDetailsResponse, error) {
|
||||
url := "/v1/report/list"
|
||||
url := "/v1/report/info"
|
||||
|
||||
resp := &GetReportDetailsResponse{}
|
||||
|
||||
|
||||
@@ -77,6 +77,15 @@ func TestGetList(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if int(resp.Result.Total) != len(resp.Result.Reports) {
|
||||
t.Errorf("Amount of reports (%d) is not equal to total (%d)", len(resp.Result.Reports), resp.Result.Total)
|
||||
}
|
||||
if len(resp.Result.Reports) > 0 {
|
||||
if resp.Result.Reports[0].Status == "" {
|
||||
t.Errorf("Status must be 'success' or 'failed'")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +138,12 @@ func TestGetReportDetails(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if resp.Result.Status == "" {
|
||||
t.Errorf("Status must be 'success' or 'failed'")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,6 +212,14 @@ func TestGetFinancialReport(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if len(resp.Result.CashFlows) > 0 {
|
||||
if resp.Result.CashFlows[0].CurrencyCode == "" {
|
||||
t.Errorf("Currency Code cannot be empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,6 +266,12 @@ func TestGetProductsReport(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if resp.Result.Code == "" {
|
||||
t.Errorf("Code cannot be empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,6 +318,12 @@ func TestGetStocksReport(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if resp.Result.Code == "" {
|
||||
t.Errorf("Code cannot be empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,6 +373,12 @@ func TestGetProductsMovementReport(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if resp.Result.Code == "" {
|
||||
t.Errorf("Code cannot be empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,6 +429,12 @@ func TestGetReturnsReport(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if resp.Result.Code == "" {
|
||||
t.Errorf("Code cannot be empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,5 +487,11 @@ func TestGetShipmentReport(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if resp.Result.Code == "" {
|
||||
t.Errorf("Code cannot be empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,15 +32,15 @@ func TestGetFBOReturns(t *testing.T) {
|
||||
"returns": [
|
||||
{
|
||||
"accepted_from_customer_moment": "2019-08-24T14:15:22Z",
|
||||
"company_id": 0,
|
||||
"company_id": 123456789,
|
||||
"current_place_name": "my-place",
|
||||
"dst_place_name": "that-place",
|
||||
"id": 0,
|
||||
"id": 123456789,
|
||||
"is_opened": true,
|
||||
"posting_number": "some number",
|
||||
"return_reason_name": "ripped",
|
||||
"returned_to_ozon_moment": "2019-08-24T14:15:22Z",
|
||||
"sku": 0,
|
||||
"sku": 123456789,
|
||||
"status_name": "delivering"
|
||||
}
|
||||
]
|
||||
@@ -69,6 +69,20 @@ func TestGetFBOReturns(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if len(resp.Returns) > 0 {
|
||||
if resp.Returns[0].Id == 0 {
|
||||
t.Errorf("Id cannot be 0")
|
||||
}
|
||||
if resp.Returns[0].CompanyId == 0 {
|
||||
t.Errorf("Company id cannot be 0")
|
||||
}
|
||||
if resp.Returns[0].SKU == 0 {
|
||||
t.Errorf("SKU cannot be 0")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,5 +166,25 @@ func TestGetFBSReturns(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if int(resp.Result.Count) != len(resp.Result.Returns) {
|
||||
t.Errorf("Count must equal to length of returns")
|
||||
}
|
||||
if len(resp.Result.Returns) > 0 {
|
||||
if resp.Result.Returns[0].Id == 0 {
|
||||
t.Errorf("Id cannot be 0")
|
||||
}
|
||||
if resp.Result.Returns[0].ProductId == 0 {
|
||||
t.Errorf("Product id cannot be 0")
|
||||
}
|
||||
if resp.Result.Returns[0].SKU == 0 {
|
||||
t.Errorf("SKU cannot be 0")
|
||||
}
|
||||
if resp.Result.Returns[0].Status == "" {
|
||||
t.Errorf("Status cannot be empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,17 @@ func TestGetListOfWarehouses(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if len(resp.Result) > 0 {
|
||||
if resp.Result[0].WarehouseId == 0 {
|
||||
t.Errorf("Warehouse id cannot be 0")
|
||||
}
|
||||
if resp.Result[0].Name == "" {
|
||||
t.Errorf("Name cannot be empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,5 +141,22 @@ func TestGetListOfDeliveryMethods(t *testing.T) {
|
||||
if resp.StatusCode != test.statusCode {
|
||||
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
if len(resp.Result) > 0 {
|
||||
if resp.Result[0].Id == 0 {
|
||||
t.Errorf("Id cannot be 0")
|
||||
}
|
||||
if resp.Result[0].Name == "" {
|
||||
t.Errorf("Name cannot be empty")
|
||||
}
|
||||
if resp.Result[0].Status == "" {
|
||||
t.Errorf("Status cannot be empty")
|
||||
}
|
||||
if resp.Result[0].WarehouseId == 0 {
|
||||
t.Errorf("Warehouse id cannot be 0")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user