164 lines
3.9 KiB
Go
164 lines
3.9 KiB
Go
package cms
|
|
|
|
import (
|
|
"fmt"
|
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
|
"git.rosy.net.cn/jx-callback/business/model"
|
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
/*
|
|
func TestGetStoresVendorSnapshot(t *testing.T) {
|
|
result, err := GetStoresVendorSnapshot(jxcontext.AdminCtx, nil, []int{model.VendorIDEBAI}, nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
t.Log(len(result))
|
|
}
|
|
|
|
func TestSendAlarmVendorSnapshot(t *testing.T) {
|
|
db := dao.GetDB()
|
|
prevSnapshotList, _ := dao.GetVendorStoreSnapshot(db, utils.Str2Time("2019-09-19 11:00:00"))
|
|
curSnapshotList, _ := dao.GetVendorStoreSnapshot(db, utils.Str2Time("2019-09-19 15:00:00"))
|
|
err := SendAlarmVendorSnapshot(jxcontext.AdminCtx, nil, prevSnapshotList, curSnapshotList)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestUpdateVendorStoreStatusBySnapshot(t *testing.T) {
|
|
db := dao.GetDB()
|
|
curSnapshotList, _ := dao.GetVendorStoreSnapshot(db, utils.Str2Time("2019-07-30 08:00:00"))
|
|
updateVendorStoreStatusBySnapshot(db, curSnapshotList)
|
|
}
|
|
*/
|
|
func TestGetBrands(t *testing.T) {
|
|
var test bool = false
|
|
if test {
|
|
return
|
|
}
|
|
|
|
}
|
|
func TestAbs(t *testing.T) {
|
|
got := 1
|
|
if got != 1 {
|
|
t.Errorf("Abs(-1) = %d; want 1", got)
|
|
}
|
|
}
|
|
|
|
func TestGetBrands1(t *testing.T) {
|
|
type args struct {
|
|
ctx *jxcontext.Context
|
|
name string
|
|
brandID int
|
|
isManage bool
|
|
}
|
|
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
wantGetBrandsResult []*GetBrandsResult
|
|
wantErr bool
|
|
}{
|
|
// TODO: Add test cases.
|
|
|
|
}
|
|
var test bool = false
|
|
if test {
|
|
return
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
gotGetBrandsResult, err := GetBrands(tt.args.ctx, tt.args.name, tt.args.brandID, tt.args.isManage)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Errorf("GetBrands() error = %v, wantErr %v", err, tt.wantErr)
|
|
return
|
|
}
|
|
if !reflect.DeepEqual(gotGetBrandsResult, tt.wantGetBrandsResult) {
|
|
t.Errorf("GetBrands() gotGetBrandsResult = %v, want %v", gotGetBrandsResult, tt.wantGetBrandsResult)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestQueryPageStores2(t *testing.T) {
|
|
type args struct {
|
|
db *dao.DaoDB
|
|
pageSize int
|
|
offset int
|
|
keyword string
|
|
vendorStoreID string
|
|
brandName string
|
|
vendorID int
|
|
cityCode int
|
|
districtCode int
|
|
tel string
|
|
minShopScore float32
|
|
minRecentOrderNum int
|
|
minSkuCount int
|
|
lng1 float64
|
|
lat1 float64
|
|
lng2 float64
|
|
lat2 float64
|
|
cat string
|
|
}
|
|
dbt := dao.GetDB()
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
wantPagedInfo *model.PagedInfo
|
|
wantErr bool
|
|
}{
|
|
// TODO: Add test cases.
|
|
{
|
|
"测试1",
|
|
args{
|
|
dbt,
|
|
15,
|
|
0,
|
|
"",
|
|
"",
|
|
"", //缺
|
|
-1,
|
|
510000,
|
|
0, //缺
|
|
"",
|
|
0,
|
|
0,
|
|
0,
|
|
104.066301,
|
|
30.572961,
|
|
104.066301,
|
|
30.572961,
|
|
"",
|
|
},
|
|
nil,
|
|
true,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
gotPagedInfo, err := QueryPageStores2(tt.args.db, tt.args.pageSize, tt.args.offset, tt.args.keyword, tt.args.vendorStoreID, tt.args.brandName, tt.args.vendorID, tt.args.cityCode, tt.args.districtCode, tt.args.tel, tt.args.minShopScore, tt.args.minRecentOrderNum, tt.args.minSkuCount, tt.args.lng1, tt.args.lat1, tt.args.lng2, tt.args.lat2, tt.args.cat)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Errorf("QueryPageStores2() error = %v, wantErr %v", err, tt.wantErr)
|
|
return
|
|
}
|
|
if !reflect.DeepEqual(gotPagedInfo, tt.wantPagedInfo) {
|
|
t.Errorf("QueryPageStores2() gotPagedInfo = %v, want %v", gotPagedInfo, tt.wantPagedInfo)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestUpdate(t *testing.T) {
|
|
UpdateStoreOperatorConfig()
|
|
}
|
|
func TestUpdateStorePoiStatus(t *testing.T) {
|
|
var ctx *jxcontext.Context
|
|
err := UpdateStorePoiStatus(ctx)
|
|
fmt.Println(err)
|
|
}
|