package mtwmapi import ( "testing" "git.rosy.net.cn/baseapi/utils" ) func TestRetailCatList(t *testing.T) { result, err := api.RetailCatList(testPoiCode) if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } func TestRetailCatUpdate(t *testing.T) { // err := api.RetailCatUpdate(testPoiCode, "测试一级类别", "测试一级类别2", "", 2) err := api.RetailCatUpdate(testPoiCode, "测试一级类别", "测试一级类别", "", 2) if err != nil { t.Fatal(err) } } func TestRetailCatDelete(t *testing.T) { var err error err = api.RetailCatDelete(testPoiCode, utils.GetUpperUUID()) if err == nil { t.Fatal("should return error that can not find such cat") } uniqueCatName := "一二三四五六七八九十" // uniqueCatName := "1234567890" //fmt.Sprintf("CAT%d", time.Now().Unix()) err = api.RetailCatUpdate(testPoiCode, "", uniqueCatName, "", 15) if err != nil { t.Fatal(err) } err = api.RetailCatDelete(testPoiCode, uniqueCatName) if err != nil { t.Fatal(err) } } func TestRetailList(t *testing.T) { result, err := api.RetailList(testPoiCode, 0, GeneralMaxLimit) if err != nil { t.Fatal(err) } if len(result) == 0 { t.Fatal("should have items") } // t.Log(utils.Format4Output(result, false)) } func TestRetailGetSpTagIds(t *testing.T) { result, err := api.RetailGetSpTagIds() if err != nil { t.Fatal(err) } if len(result) == 0 { t.Fatal("should have items") } t.Log(utils.Format4Output(result, false)) } func TestRetailCatSkuBatchDelete(t *testing.T) { err := api.RetailCatSkuBatchDelete(testPoiCode, []string{"测试一级类别"}, nil, nil) if err != nil { t.Fatal(err) } } func TestRetailDelete(t *testing.T) { err := api.RetailDelete(testPoiCode, "") if err != nil { t.Fatal(err) } } func TestRetailBatchInitData(t *testing.T) { err := api.RetailBatchInitData("2464052", []map[string]interface{}{ map[string]interface{}{ "app_food_code": "23841", "box_num": 0, "box_price": 0, "category_name": "豆制良品🌾🌾", "description": "", "is_sold_out": 0, "min_order_count": 1, "name": "干腐竹约150g/份", "picture": "http://image.jxc4.com/5f7fba025fc9348796039423c48ac3f5.jpg", "price": 1000, "skus": []map[string]interface{}{ map[string]interface{}{ "price": 1000, "sku_id": "23841", "spec": "150g", "stock": "*", "upc": "", }, }, "tag_id": "200000380", "unit": "份", }, }) if err != nil { t.Fatal(err) } }