diff --git a/backend/database/mongo_test.go b/backend/database/mongo_test.go index a73ae6df..b875b91a 100644 --- a/backend/database/mongo_test.go +++ b/backend/database/mongo_test.go @@ -1,6 +1,7 @@ package database import ( + "crawlab/config" . "github.com/smartystreets/goconvey/convey" "github.com/spf13/viper" "testing" @@ -8,12 +9,20 @@ import ( func TestGetDb(t *testing.T) { Convey("Test GetDb", t, func() { + if err := config.InitConfig(""); err != nil { + t.Fatal("Init config failed") + } + t.Log("初始化配置成功") + err := InitMongo() + if err != nil { + t.Fatal("Init mongodb failed") + } s, db := GetDb() Convey("The value should be Session.Copy", func() { - So(s, ShouldEqual, Session.Copy()) + So(s, ShouldResemble, Session.Copy()) }) Convey("The value should be reference of database", func() { - So(db, ShouldEqual, s.DB(viper.GetString("mongo.db"))) + So(db, ShouldResemble, s.DB(viper.GetString("mongo.db"))) }) }) }