- store and product api for jd and elm added.
This commit is contained in:
89
platformapi/elmapi/product_test.go
Normal file
89
platformapi/elmapi/product_test.go
Normal file
@@ -0,0 +1,89 @@
|
||||
package elmapi
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
func TestGetShopCategoriesWithChildren(t *testing.T) {
|
||||
result, err := elmapi.GetShopCategoriesWithChildren(157451618)
|
||||
if err != nil || len(result) == 0 {
|
||||
t.Fatalf("GetShopCategoriesWithChildren failed with error:%v", err)
|
||||
}
|
||||
sugarLogger.Debug(result[0])
|
||||
}
|
||||
|
||||
func TestGetCategoryWithChildren(t *testing.T) {
|
||||
result, err := elmapi.GetCategoryWithChildren(538250690)
|
||||
if err != nil || result == nil {
|
||||
t.Fatalf("GetCategoryWithChildren failed with error:%v", err)
|
||||
}
|
||||
sugarLogger.Debug(result)
|
||||
}
|
||||
|
||||
func TestGetBackCategory(t *testing.T) {
|
||||
result, err := elmapi.GetBackCategory(157451618)
|
||||
if err != nil || len(result) == 0 {
|
||||
t.Fatalf("GetBackCategory failed with error:%v", err)
|
||||
}
|
||||
sugarLogger.Debug(result[0])
|
||||
}
|
||||
|
||||
func TestGetItemsByCategoryId(t *testing.T) {
|
||||
result, err := elmapi.GetItemsByCategoryId(1240437151)
|
||||
if err != nil {
|
||||
t.Fatalf("GetItemsByCategoryId failed with error:%v", err)
|
||||
}
|
||||
sugarLogger.Debug(string(utils.MustMarshal(result[0])))
|
||||
}
|
||||
|
||||
func TestGetItem(t *testing.T) {
|
||||
result, err := elmapi.GetItem(684455990)
|
||||
if err != nil {
|
||||
t.Fatalf("GetItem failed with error:%v", err)
|
||||
}
|
||||
sugarLogger.Debug(string(utils.MustMarshal(result)))
|
||||
}
|
||||
|
||||
func TestBatchGetItems(t *testing.T) {
|
||||
result, err := elmapi.BatchGetItems([]int64{684460503, 684455990})
|
||||
if err != nil && len(result) != 2 {
|
||||
t.Fatalf("BatchGetItems failed with error:%v", err)
|
||||
}
|
||||
if utils.MustInterface2Int64(result[1]["id"]) != 684455990 {
|
||||
t.Fatal("BatchGetItems get wrong data")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetItemByShopIdAndExtendCode(t *testing.T) {
|
||||
result, err := elmapi.GetItemByShopIdAndExtendCode(162936407, "920")
|
||||
if err != nil && result["id"] != 816260193 {
|
||||
t.Fatalf("GetItemByShopIdAndExtendCode failed with error:%v, result:%v", err, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetShopSalesItems(t *testing.T) {
|
||||
result, err := elmapi.GetShopSalesItems(157465459)
|
||||
if err != nil && len(result) == 0 {
|
||||
t.Fatalf("GetShopSalesItems failed with error:%v, result:%v", err, result)
|
||||
}
|
||||
sugarLogger.Debug(result)
|
||||
}
|
||||
|
||||
func TestQueryItemByPage(t *testing.T) {
|
||||
limit := 20
|
||||
result, err := elmapi.QueryItemByPage(157465459, 0, limit)
|
||||
if err != nil && len(result) != limit {
|
||||
t.Fatalf("QueryItemByPage failed with error:%v, result:%v", err, result)
|
||||
}
|
||||
// sugarLogger.Debug(result)
|
||||
}
|
||||
|
||||
func TestGetImageUrl(t *testing.T) {
|
||||
result, err := elmapi.GetImageUrl("6a6c9de7311caccfe8fb1c839ba7aa15jpeg")
|
||||
if err != nil && result == "" {
|
||||
t.Fatalf("GetImageUrl failed with error:%v, result:%v", err, result)
|
||||
}
|
||||
// sugarLogger.Debug(result)
|
||||
}
|
||||
Reference in New Issue
Block a user