-
Notifications
You must be signed in to change notification settings - Fork 2
/
mongotest_test.go
35 lines (29 loc) · 899 Bytes
/
mongotest_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package mongotest_test
import (
"testing"
"github.com/pinzolo/mongotest"
)
func TestTry(t *testing.T) {
if err := mongotest.Try(); err != nil {
t.Error(err)
}
}
func TestTryWithEmptyURL(t *testing.T) {
defer mongotest.DefaultConfig()()
if err := mongotest.Try(); err == nil {
t.Error("Try should return error when Database URL is empty")
}
}
func TestTryWithEmptyDatabase(t *testing.T) {
defer mongotest.DefaultConfig()()
defer mongotest.Reconfigure(mongotest.Config{URL: "mongodb://root:password@localhost:27017"})()
if err := mongotest.Try(); err == nil {
t.Error("Try should return error when Database name is empty")
}
}
func TestTryWithInvalidURL(t *testing.T) {
defer mongotest.Reconfigure(mongotest.Config{URL: "mongodb://root:password@localhost:2701"})()
if err := mongotest.Try(); err == nil {
t.Error("Try should return error when Database URL is invalid")
}
}