63 lines
1.3 KiB
Go
63 lines
1.3 KiB
Go
package dao
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
"git.rosy.net.cn/jx-callback/business/model"
|
|
"git.rosy.net.cn/jx-callback/globals"
|
|
"git.rosy.net.cn/jx-callback/globals/testinit"
|
|
)
|
|
|
|
func init() {
|
|
testinit.Init()
|
|
}
|
|
|
|
func TestSelectEntities(t *testing.T) {
|
|
places := []*model.Place{}
|
|
GetRows(nil, &places, `
|
|
SELECT DISTINCT t3.*
|
|
FROM sku_name_place_bind t1
|
|
JOIN place t2 ON t1.place_code = t2.code
|
|
JOIN place t3 ON (t2.level = 2 AND t2.code = t3.code) OR (t2.level = 1 AND t2.code = t3.parent_code)
|
|
WHERE t1.name_id = ?
|
|
`, 40)
|
|
|
|
globals.SugarLogger.Debug(utils.Format4Output(places, false))
|
|
}
|
|
|
|
func TestGetPlaceByName(t *testing.T) {
|
|
result, err := GetPlaceByName(nil, "青羊", 3, 510100)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(result)
|
|
}
|
|
|
|
func TestUpdateKV(t *testing.T) {
|
|
dummy := &model.Store{}
|
|
kvs := map[string]interface{}{
|
|
"status": 100,
|
|
"Tel1": "tel1",
|
|
"tEl2": "tel2",
|
|
"deliveryRangeType": 15,
|
|
}
|
|
cond := map[string]interface{}{
|
|
"id": 100002,
|
|
}
|
|
num, err := UpdateEntityLogically(nil, dummy, kvs, "autotest", cond)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(num)
|
|
}
|
|
|
|
func TestWrapAddIDCULEntity(t *testing.T) {
|
|
dummy := &model.Store{}
|
|
WrapAddIDCULEntity(dummy, "autotest")
|
|
if dummy.LastOperator != "autotest" {
|
|
t.Fatal("last operator is not same")
|
|
}
|
|
t.Log(dummy)
|
|
}
|