! 饿百API对于门店商品批处理的返回结果发生改变,部分失败时返回错误(之前除了改价,返回的是成功),详情是错误信息中(之前在Data中)

This commit is contained in:
gazebo
2019-07-26 10:24:31 +08:00
parent f2539cf572
commit e34ffd277f
3 changed files with 117 additions and 54 deletions

View File

@@ -115,19 +115,45 @@ func TestSkuShopCategoryMap(t *testing.T) {
}
func TestSkuDelete(t *testing.T) {
failedSkuIDs, err := api.SkuDelete(testShopID, []int64{12345678, 12423432}, nil)
if err != nil {
// t.Fatal(err)
const (
notExistSkuID = 12345678
existSkuID = 156406677407848
)
opResult, err := api.SkuDelete(testShopID, []int64{notExistSkuID}, nil)
t.Log(utils.Format4Output(opResult, false))
if err == nil {
t.Log("应该要报错")
}
t.Log(utils.Format4Output(failedSkuIDs, false))
}
func TestSkuOnline(t *testing.T) {
failedSkuIDs, err := api.SkuOnline(testShopID, []int64{156369111807787, 12345678, 12423432}, nil, nil)
if opResult == nil || len(opResult.FailedList) != 1 || opResult.FailedList[0].SkuID != notExistSkuID {
t.Logf("错误结果中应该要包含:%d", notExistSkuID)
}
opResult, err = api.SkuDelete(testShopID, []int64{existSkuID}, nil)
t.Log(utils.Format4Output(opResult, false))
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(failedSkuIDs, false))
if opResult == nil || len(opResult.SuccessList) != 1 || opResult.SuccessList[0].SkuID != existSkuID {
t.Logf("成功结果中应该要包含:%d", existSkuID)
}
}
func TestSkuOnline(t *testing.T) {
const (
notExistSkuID = 12345678
existSkuID = 156406688807623
)
opResult, err := api.SkuOnline(testShopID, []int64{notExistSkuID, existSkuID}, nil, nil)
t.Log(utils.Format4Output(opResult, false))
if err == nil {
t.Log("应该要报错")
}
if opResult == nil || len(opResult.FailedList) != 1 || opResult.FailedList[0].SkuID != notExistSkuID {
t.Logf("错误结果中应该要包含:%d", notExistSkuID)
}
if opResult == nil || len(opResult.SuccessList) != 1 || opResult.SuccessList[0].SkuID != existSkuID {
t.Logf("成功结果中应该要包含:%d", existSkuID)
}
}
func TestSkuOnlineOne(t *testing.T) {
@@ -138,15 +164,15 @@ func TestSkuOnlineOne(t *testing.T) {
}
func TestSkuOffline(t *testing.T) {
failedSkuIDs, err := api.SkuOffline(testShopID, []int64{156291398007698, 12345678, 12423432}, nil, nil)
opResult, err := api.SkuOffline(testShopID, []int64{1564049914071288, 156389470507185}, nil, nil)
t.Log(utils.Format4Output(opResult, false))
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(failedSkuIDs, false))
}
func TestSkuPriceUpdateBatch(t *testing.T) {
failedSkuIDs, err := api.SkuPriceUpdateBatch(testShopID, ShopSkuInfoList{
opResult, err := api.SkuPriceUpdateBatch(testShopID, ShopSkuInfoList{
&ShopSkuInfo{
SkuID: 156369111807787,
SalePrice: 100,
@@ -160,14 +186,17 @@ func TestSkuPriceUpdateBatch(t *testing.T) {
SalePrice: 100,
},
}, SkuIDTypeSkuID)
if err != nil {
t.Fatal(err)
t.Log(utils.Format4Output(opResult, false))
if err == nil {
t.Fatal("应该要报错才对")
}
if len(opResult.FailedList) != 3 {
t.Fatal("错误列表不正确")
}
t.Log(utils.Format4Output(failedSkuIDs, false))
}
func TestSkuStockUpdateBatch(t *testing.T) {
failedSkuIDs, err := api.SkuStockUpdateBatch(testShopID, ShopSkuInfoList{
opResult, err := api.SkuStockUpdateBatch(testShopID, ShopSkuInfoList{
&ShopSkuInfo{
SkuID: 156291398007698,
Stock: 2,
@@ -181,10 +210,13 @@ func TestSkuStockUpdateBatch(t *testing.T) {
Stock: 2,
},
}, SkuIDTypeSkuID)
if err != nil {
t.Fatal(err)
t.Log(utils.Format4Output(opResult, false))
if err == nil {
t.Fatal("应该要报错才对")
}
if len(opResult.FailedList) != 3 {
t.Fatal("错误列表不正确")
}
t.Log(utils.Format4Output(failedSkuIDs, false))
}
func TestGetEbaiCatIDFromName(t *testing.T) {