- basic store api added.
This commit is contained in:
104
platformapi/jdapi/store_test.go
Normal file
104
platformapi/jdapi/store_test.go
Normal file
@@ -0,0 +1,104 @@
|
||||
package jdapi
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
mustExistStoreID = "11738324"
|
||||
)
|
||||
|
||||
func TestGetStationsByVenderId(t *testing.T) {
|
||||
result, err := jdapi.GetStationsByVenderId()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
findStore := false
|
||||
for _, v := range result {
|
||||
if v == mustExistStoreID {
|
||||
findStore = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !findStore {
|
||||
baseapi.SugarLogger.Fatal("result have no store:%s", mustExistStoreID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetStoreInfoByStationNo(t *testing.T) {
|
||||
result, err := jdapi.GetStoreInfoByStationNo(mustExistStoreID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
outSystemId := result["outSystemId"].(string)
|
||||
if outSystemId != "100285" {
|
||||
baseapi.SugarLogger.Fatal("outSystemId is not correct, its:%s", outSystemId)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateStoreInfo4Open(t *testing.T) {
|
||||
result, err := jdapi.GetStoreInfoByStationNo(mustExistStoreID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
oldAddress := result["stationAddress"].(string)
|
||||
testAddress := oldAddress + "T"
|
||||
addParams := map[string]interface{}{
|
||||
"stationAddress": testAddress,
|
||||
}
|
||||
updateResult, err := jdapi.UpdateStoreInfo4Open(mustExistStoreID, "test", addParams)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
baseapi.SugarLogger.Debug(updateResult)
|
||||
time.Sleep(2 * time.Second)
|
||||
result, err = jdapi.GetStoreInfoByStationNo(mustExistStoreID)
|
||||
addParams = map[string]interface{}{
|
||||
"stationAddress": oldAddress,
|
||||
}
|
||||
jdapi.UpdateStoreInfo4Open(mustExistStoreID, "test", addParams)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
restoredAddress := result["stationAddress"].(string)
|
||||
if restoredAddress != oldAddress {
|
||||
t.Fatalf("address not match, it's:%s", restoredAddress)
|
||||
}
|
||||
}
|
||||
func TestGetCommentByOrderId(t *testing.T) {
|
||||
testOrderID := int64(819498819000341)
|
||||
result, err := jdapi.GetCommentByOrderId(testOrderID)
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
gotOrderID := utils.MustInterface2Int64(result["orderId"])
|
||||
if gotOrderID != testOrderID {
|
||||
t.Fatalf("GetCommentByOrderId wrong, gotOrderID:%d", gotOrderID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateStoreConfig4Open(t *testing.T) {
|
||||
testStationNo := "11785740"
|
||||
desiredValue := true
|
||||
// 马上修改了后,通过GetStoreInfoByStationNo得到的数据不及时,测试不能过的。。。
|
||||
result, err := jdapi.UpdateStoreConfig4Open(testStationNo, desiredValue)
|
||||
if err != nil || !result {
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
t.Fatal(result)
|
||||
}
|
||||
time.Sleep(2 * time.Second)
|
||||
result2, err := jdapi.GetStoreInfoByStationNo(testStationNo)
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
isAutoOrder := int(utils.MustInterface2Int64(result2["isAutoOrder"]))
|
||||
if isAutoOrder != 0 && desiredValue || isAutoOrder == 0 && !desiredValue {
|
||||
t.Fatalf("UpdateStoreConfig4Open failed, isAutoOrder:%d", isAutoOrder)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user