mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-22 17:31:03 +01:00
bug fix: fixed mongo.go unit test
This commit is contained in:
@@ -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")))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user