Browse Source

add other StoreHost support

pull/202/head
yedf2 4 years ago
parent
commit
d7b8949ac2
  1. 5
      test/busi/base_types.go
  2. 6
      test/busi/utils.go

5
test/busi/base_types.go

@ -17,10 +17,13 @@ import (
"go.mongodb.org/mongo-driver/bson"
)
// StoreHost examples will connect to dtm.pub; tests will connect to localhost
var StoreHost = "localhost"
// BusiConf 1
var BusiConf = dtmcli.DBConf{
Driver: "mysql",
Host: "localhost",
Host: StoreHost,
Port: 3306,
User: "root",
}

6
test/busi/utils.go

@ -5,7 +5,6 @@ import (
"database/sql"
"encoding/json"
"fmt"
"os"
"strings"
sync "sync"
"time"
@ -130,7 +129,7 @@ func RedisGet() *redis.Client {
once.Do(func() {
logger.Debugf("connecting to client redis")
rdb = redis.NewClient(&redis.Options{
Addr: dtmimp.OrString(os.Getenv("BUSI_REDIS"), "localhost:6379"),
Addr: fmt.Sprintf("%s:6379", StoreHost),
Username: "root",
Password: "",
})
@ -146,8 +145,9 @@ var (
// MongoGet get mongo client
func MongoGet() *mongo.Client {
mongoOnce.Do(func() {
uri := fmt.Sprintf("mongodb://%s:27017/?retryWrites=false", StoreHost)
ctx := context.Background()
client, err := mongo.Connect(ctx, options.Client().ApplyURI("mongodb://localhost:27017/?retryWrites=false"))
client, err := mongo.Connect(ctx, options.Client().ApplyURI(uri))
dtmimp.E2P(err)
mongoc = client
})

Loading…
Cancel
Save