log delete
This commit is contained in:
@@ -1,159 +1,160 @@
|
||||
package jdapi
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
mustExistStoreID = "11053496"
|
||||
mustExistStoreJXID = "2"
|
||||
|
||||
// mustExistStoreID = "11734851"
|
||||
// mustExistStoreJXID = "100118"
|
||||
)
|
||||
|
||||
func TestGetAllCities(t *testing.T) {
|
||||
result, err := api.GetAllCities()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestGetStationsByVenderId(t *testing.T) {
|
||||
result, err := api.GetStationsByVenderId()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
findStore := false
|
||||
for _, v := range result {
|
||||
if v == mustExistStoreID {
|
||||
findStore = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !findStore {
|
||||
baseapi.SugarLogger.Fatalf("result have no store:%s", mustExistStoreID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetStoreInfoByStationNo(t *testing.T) {
|
||||
result, err := api.GetStoreInfoByStationNo2("11946249")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
|
||||
}
|
||||
|
||||
func TestUpdateStoreInfo4Open(t *testing.T) {
|
||||
result, err := api.GetStoreInfoByStationNo2(mustExistStoreID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
oldAddress := result.StationAddress
|
||||
params := &OpStoreParams{
|
||||
StationNo: mustExistStoreID,
|
||||
Operator: "test",
|
||||
StationAddress: oldAddress + "T",
|
||||
}
|
||||
err = api.UpdateStoreInfo4Open2(params, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
result, err = api.GetStoreInfoByStationNo2(mustExistStoreID)
|
||||
newAddress := result.StationAddress
|
||||
if newAddress != params.StationAddress {
|
||||
t.Fatalf("address not match, newAddress:%s, oldAddress:%s", newAddress, oldAddress)
|
||||
}
|
||||
|
||||
params.StationAddress = oldAddress
|
||||
api.UpdateStoreInfo4Open2(params, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCommentByOrderId(t *testing.T) {
|
||||
testOrderID := int64(922520919000622)
|
||||
result, err := api.GetCommentByOrderId2(testOrderID)
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestUpdateStoreConfig4Open(t *testing.T) {
|
||||
testStationNo := "11785740"
|
||||
desiredValue := true
|
||||
// 马上修改了后,通过GetStoreInfoByStationNo得到的数据不及时,测试不能过的。。。
|
||||
result, err := api.UpdateStoreConfig4Open(testStationNo, desiredValue)
|
||||
if err != nil || !result {
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
t.Fatal(result)
|
||||
}
|
||||
time.Sleep(2 * time.Second)
|
||||
result2, err := api.GetStoreInfoByStationNo2(testStationNo)
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
isAutoOrder := result2.IsAutoOrder
|
||||
if isAutoOrder != 0 && desiredValue || isAutoOrder == 0 && !desiredValue {
|
||||
t.Fatalf("UpdateStoreConfig4Open failed, isAutoOrder:%d", isAutoOrder)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDisableAutoOrder4AllStores(t *testing.T) {
|
||||
storeIDs, err := api.GetStationsByVenderId()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, storeID := range storeIDs {
|
||||
if storeInfo, err := api.GetStoreInfoByStationNo2(storeID); err == nil {
|
||||
if storeInfo.Yn == 0 && storeInfo.IsAutoOrder == 0 {
|
||||
t.Log(storeID)
|
||||
api.UpdateStoreConfig4Open(storeID, false)
|
||||
}
|
||||
t.Log(utils.Format4Output(storeInfo, false))
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateStoreFreightConfigNew(t *testing.T) {
|
||||
err := api.UpdateStoreFreightConfigNew(&UpdateStoreFreightParam{
|
||||
UserPin: "test",
|
||||
MerchantStationNo: "2",
|
||||
OpenDistanceFreight: true,
|
||||
IsFullFree: true,
|
||||
|
||||
StartCharge: 1890,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetDeliveryRangeByStationNo(t *testing.T) {
|
||||
const testStoreID = "11946249"
|
||||
result, err := api.GetDeliveryRangeByStationNo2(testStoreID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
baseapi.SugarLogger.Debug(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestQueryMerchantMemberInfo(t *testing.T) {
|
||||
result, err := api.GetCommonMemberRegisteredInfo("562012843072000442")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
baseapi.SugarLogger.Debug(utils.Format4Output(result, false))
|
||||
}
|
||||
//
|
||||
//import (
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "git.rosy.net.cn/baseapi"
|
||||
// "git.rosy.net.cn/baseapi/utils"
|
||||
//)
|
||||
//
|
||||
//const (
|
||||
// mustExistStoreID = "11053496"
|
||||
// mustExistStoreJXID = "2"
|
||||
//
|
||||
// // mustExistStoreID = "11734851"
|
||||
// // mustExistStoreJXID = "100118"
|
||||
//)
|
||||
//
|
||||
//func TestGetAllCities(t *testing.T) {
|
||||
// result, err := api.GetAllCities()
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
//}
|
||||
//
|
||||
//func TestGetStationsByVenderId(t *testing.T) {
|
||||
// result, err := api.GetStationsByVenderId()
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// findStore := false
|
||||
// for _, v := range result {
|
||||
// if v == mustExistStoreID {
|
||||
// findStore = true
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// if !findStore {
|
||||
// baseapi.SugarLogger.Fatalf("result have no store:%s", mustExistStoreID)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func TestGetStoreInfoByStationNo(t *testing.T) {
|
||||
// result, err := api.GetStoreInfoByStationNo2("11946249")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
//
|
||||
//}
|
||||
//
|
||||
//func TestUpdateStoreInfo4Open(t *testing.T) {
|
||||
// result, err := api.GetStoreInfoByStationNo2(mustExistStoreID)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// oldAddress := result.StationAddress
|
||||
// params := &OpStoreParams{
|
||||
// StationNo: mustExistStoreID,
|
||||
// Operator: "test",
|
||||
// StationAddress: oldAddress + "T",
|
||||
// }
|
||||
// err = api.UpdateStoreInfo4Open2(params, false)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
//
|
||||
// result, err = api.GetStoreInfoByStationNo2(mustExistStoreID)
|
||||
// newAddress := result.StationAddress
|
||||
// if newAddress != params.StationAddress {
|
||||
// t.Fatalf("address not match, newAddress:%s, oldAddress:%s", newAddress, oldAddress)
|
||||
// }
|
||||
//
|
||||
// params.StationAddress = oldAddress
|
||||
// api.UpdateStoreInfo4Open2(params, false)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func TestGetCommentByOrderId(t *testing.T) {
|
||||
// testOrderID := int64(922520919000622)
|
||||
// result, err := api.GetCommentByOrderId2(testOrderID)
|
||||
// if err != nil {
|
||||
// t.Fatal(err.Error())
|
||||
// }
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
//}
|
||||
//
|
||||
//func TestUpdateStoreConfig4Open(t *testing.T) {
|
||||
// testStationNo := "11785740"
|
||||
// desiredValue := true
|
||||
// // 马上修改了后,通过GetStoreInfoByStationNo得到的数据不及时,测试不能过的。。。
|
||||
// result, err := api.UpdateStoreConfig4Open(testStationNo, desiredValue)
|
||||
// if err != nil || !result {
|
||||
// if err != nil {
|
||||
// t.Fatal(err.Error())
|
||||
// }
|
||||
// t.Fatal(result)
|
||||
// }
|
||||
// time.Sleep(2 * time.Second)
|
||||
// result2, err := api.GetStoreInfoByStationNo2(testStationNo)
|
||||
// if err != nil {
|
||||
// t.Fatal(err.Error())
|
||||
// }
|
||||
// isAutoOrder := result2.IsAutoOrder
|
||||
// if isAutoOrder != 0 && desiredValue || isAutoOrder == 0 && !desiredValue {
|
||||
// t.Fatalf("UpdateStoreConfig4Open failed, isAutoOrder:%d", isAutoOrder)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func TestDisableAutoOrder4AllStores(t *testing.T) {
|
||||
// storeIDs, err := api.GetStationsByVenderId()
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// for _, storeID := range storeIDs {
|
||||
// if storeInfo, err := api.GetStoreInfoByStationNo2(storeID); err == nil {
|
||||
// if storeInfo.Yn == 0 && storeInfo.IsAutoOrder == 0 {
|
||||
// t.Log(storeID)
|
||||
// api.UpdateStoreConfig4Open(storeID, false)
|
||||
// }
|
||||
// t.Log(utils.Format4Output(storeInfo, false))
|
||||
// }
|
||||
// break
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func TestUpdateStoreFreightConfigNew(t *testing.T) {
|
||||
// err := api.UpdateStoreFreightConfigNew(&UpdateStoreFreightParam{
|
||||
// UserPin: "test",
|
||||
// MerchantStationNo: "2",
|
||||
// OpenDistanceFreight: true,
|
||||
// IsFullFree: true,
|
||||
//
|
||||
// StartCharge: 1890,
|
||||
// })
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func TestGetDeliveryRangeByStationNo(t *testing.T) {
|
||||
// const testStoreID = "11946249"
|
||||
// result, err := api.GetDeliveryRangeByStationNo2(testStoreID)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// baseapi.SugarLogger.Debug(utils.Format4Output(result, false))
|
||||
//}
|
||||
//
|
||||
//func TestQueryMerchantMemberInfo(t *testing.T) {
|
||||
// result, err := api.GetCommonMemberRegisteredInfo("562012843072000442")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// baseapi.SugarLogger.Debug(utils.Format4Output(result, false))
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user