134 lines
3.1 KiB
Go
134 lines
3.1 KiB
Go
package jdapi
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.rosy.net.cn/baseapi"
|
|
)
|
|
|
|
func TestQueryPageBrandInfo(t *testing.T) {
|
|
result, _, err := jdapi.QueryPageBrandInfo(0, 0, 0, "")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(result) == 0 {
|
|
t.Fatal("QueryPageBrandInfo brand list is empty!")
|
|
}
|
|
// baseapi.SugarLogger.Debug(result[0])
|
|
}
|
|
|
|
func TestQueryCategoriesByOrgCode(t *testing.T) {
|
|
result, err := jdapi.QueryCategoriesByOrgCode()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(result) == 0 {
|
|
t.Fatal("QueryCategoriesByOrgCode category list is empty!")
|
|
}
|
|
}
|
|
|
|
func TestQueryChildCategoriesForOP(t *testing.T) {
|
|
result, err := jdapi.QueryChildCategoriesForOP(0)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(result) == 0 {
|
|
t.Fatal("QueryChildCategoriesForOP jd category list is empty!")
|
|
}
|
|
}
|
|
|
|
func TestBatchUpdateOutSkuId(t *testing.T) {
|
|
// result, err := jdapi.BatchUpdateOutSkuId([]*SkuIDPair{
|
|
// &SkuIDPair{
|
|
// SkuId: 2012286955,
|
|
// OutSkuId: "1",
|
|
// },
|
|
// &SkuIDPair{
|
|
// SkuId: 2012286956,
|
|
// OutSkuId: "2",
|
|
// },
|
|
// &SkuIDPair{
|
|
// SkuId: 2012286957,
|
|
// OutSkuId: "3",
|
|
// },
|
|
// })
|
|
// baseapi.SugarLogger.Debug(result, err)
|
|
}
|
|
|
|
func TestQuerySkuInfos(t *testing.T) {
|
|
pageSize := 20
|
|
result, totalCount, err := jdapi.QuerySkuInfos("", 0, 0, pageSize, true)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(result) != pageSize || totalCount == 0 {
|
|
baseapi.SugarLogger.Debug(result)
|
|
t.Fatalf("QuerySkuInfos result size is not same as requested:%d", pageSize)
|
|
}
|
|
}
|
|
|
|
func TestQueryListBySkuIds(t *testing.T) {
|
|
ids := []int64{
|
|
2018806493,
|
|
2018805873,
|
|
}
|
|
result, err := jdapi.QueryListBySkuIds(ids, nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(result) != len(ids) {
|
|
baseapi.SugarLogger.Debug(result)
|
|
t.Fatalf("QueryListBySkuIds result size is not same as requested:%d", len(ids))
|
|
}
|
|
}
|
|
|
|
func TestQueryKeyWordDicInfo(t *testing.T) {
|
|
result, totalCount, err := jdapi.QueryKeyWordDicInfo(0, 0, "")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(result) == 0 || totalCount == 0 {
|
|
t.Fatalf("QueryKeyWordDicInfo size is wrong")
|
|
}
|
|
// baseapi.SugarLogger.Debug(result[0], totalCount)
|
|
}
|
|
|
|
func TestSyncProduct(t *testing.T) {
|
|
result, err := jdapi.SyncProduct("11732425", "2015717812")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
baseapi.SugarLogger.Debug(result)
|
|
result, err = jdapi.SyncProduct("wrongstoreid", "2015717812")
|
|
if err == nil {
|
|
t.Fatal("SyncProduct should return error")
|
|
}
|
|
result, err = jdapi.SyncProduct("11732425", "wrongskuid")
|
|
if err == nil {
|
|
t.Fatal("SyncProduct should return error")
|
|
}
|
|
}
|
|
|
|
func TestGetProductStatust(t *testing.T) {
|
|
result, err := jdapi.GetProductStatus("11732425", "2015717812")
|
|
if err != nil || result == nil {
|
|
t.Fatal(err)
|
|
}
|
|
// baseapi.SugarLogger.Debug(result)
|
|
result, err = jdapi.GetProductStatus("wrongstoreid", "2015717812")
|
|
if err == nil {
|
|
t.Fatal("GetProductStatus should return error")
|
|
}
|
|
result, err = jdapi.GetProductStatus("11732425", "wrongskuid")
|
|
if err == nil {
|
|
t.Fatal("GetProductStatus should return error")
|
|
}
|
|
}
|
|
|
|
func TestDelShopCategory(t *testing.T) {
|
|
err := jdapi.DelShopCategory(4784689)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|