added test for connect mongo replicaset and default
This commit is contained in:
parent
b14c114d25
commit
3ec559676d
38
mongo/mongo_test.go
Normal file
38
mongo/mongo_test.go
Normal file
@ -0,0 +1,38 @@
|
||||
package mongo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestConnectMongo(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), 15*time.Second)
|
||||
defer cancel()
|
||||
d, err := Connect(ctx, &ConnectDeps{
|
||||
Configuration: &Configuration{
|
||||
URL: "mongodb://localhost:27017,localhost:27018,localhost:27019/?replicaSet=rs0&readPreference=primary&ssl=false",
|
||||
User: "test",
|
||||
Password: "test",
|
||||
Auth: "admin",
|
||||
DatabaseName: "test_replicaset",
|
||||
},
|
||||
Timeout: 10 * time.Second,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
d.Drop(ctx)
|
||||
|
||||
d2, err := Connect(ctx, &ConnectDeps{
|
||||
Configuration: &Configuration{
|
||||
URL: "mongodb://localhost:27020/",
|
||||
User: "test",
|
||||
Password: "test",
|
||||
Auth: "admin",
|
||||
DatabaseName: "test_default",
|
||||
},
|
||||
Timeout: 10 * time.Second,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
d2.Drop(ctx)
|
||||
}
|
Loading…
Reference in New Issue
Block a user