上传测试脚本代码
This commit is contained in:
parent
76cdd23c91
commit
ea15865a4a
@ -63,7 +63,7 @@ func SetRedis_Single_PoolSize(v int) Option {
|
||||
o.Redis_Single_PoolSize = v
|
||||
}
|
||||
}
|
||||
func Redis_Cluster_Addr(v []string) Option {
|
||||
func SetRedis_Cluster_Addr(v []string) Option {
|
||||
return func(o *Options) {
|
||||
o.Redis_Cluster_Addr = v
|
||||
}
|
||||
|
@ -2,20 +2,24 @@ package pack_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/sys/cache"
|
||||
"go_dreamfactory/lego/sys/mgo"
|
||||
"go_dreamfactory/lego/sys/redis"
|
||||
"go_dreamfactory/sys/configure"
|
||||
"go_dreamfactory/sys/db"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var db mgo.ISys
|
||||
var cache redis.ISys
|
||||
|
||||
//测试环境下初始化db和cache 系统
|
||||
func TestMain(m *testing.M) {
|
||||
if err := db.OnInit(nil, db.Set_MongodbUrl("mongodb://admin:123456@10.0.0.9:27018"), db.Set_MongodbDatabase("dreamfactory")); err != nil {
|
||||
var err error
|
||||
if db, err = mgo.NewSys(nil, mgo.SetMongodbUrl("mongodb://admin:123456@10.0.0.9:27018"), mgo.SetMongodbDatabase("dreamfactory")); err != nil {
|
||||
fmt.Printf("err:%v\n", err)
|
||||
return
|
||||
}
|
||||
if err := cache.OnInit(nil, cache.Set_Redis_Addr([]string{"10.0.0.9:9001", "10.0.0.9:9002", "10.0.0.9:9003", "10.0.1.45:9004", "10.0.1.45:9005", "10.0.1.45:9006"}), cache.Set_Redis_Password("")); err != nil {
|
||||
if cache, err = redis.NewSys(nil, redis.SetRedisType(redis.Redis_Cluster), redis.SetRedis_Cluster_Addr([]string{"10.0.0.9:9001", "10.0.0.9:9002", "10.0.0.9:9003", "10.0.1.45:9004", "10.0.1.45:9005", "10.0.1.45:9006"}), redis.SetRedis_Cluster_Password("")); err != nil {
|
||||
fmt.Printf("err:%v\n", err)
|
||||
return
|
||||
}
|
||||
@ -25,3 +29,7 @@ func TestMain(m *testing.M) {
|
||||
}
|
||||
defer os.Exit(m.Run())
|
||||
}
|
||||
|
||||
func Test_Log(t *testing.T) {
|
||||
db.InsertOne("", 1)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user