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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
package db
import (
"github.com/mongodb/mongo-tools/common/options"
"github.com/mongodb/mongo-tools/common/testutil"
. "github.com/smartystreets/goconvey/convey"
"reflect"
"testing"
)
func TestNewSessionProvider(t *testing.T) {
testutil.VerifyTestType(t, "db")
Convey("When initializing a session provider", t, func() {
Convey("with the standard options, a provider with a standard"+
" connector should be returned", func() {
opts := options.ToolOptions{
Connection: &options.Connection{
Port: DefaultTestPort,
},
SSL: &options.SSL{},
Auth: &options.Auth{},
}
provider, err := NewSessionProvider(opts)
So(err, ShouldBeNil)
So(reflect.TypeOf(provider.connector), ShouldEqual,
reflect.TypeOf(&VanillaDBConnector{}))
})
Convey("the master session should be successfully "+
" initialized", func() {
opts := options.ToolOptions{
Connection: &options.Connection{
Port: DefaultTestPort,
},
SSL: &options.SSL{},
Auth: &options.Auth{},
}
provider, err := NewSessionProvider(opts)
So(err, ShouldBeNil)
So(provider.masterSession, ShouldBeNil)
session, err := provider.GetSession()
So(err, ShouldBeNil)
So(session, ShouldNotBeNil)
So(provider.masterSession, ShouldNotBeNil)
})
})
}
type listDatabasesCommand struct {
Databases []map[string]interface{} `json:"databases"`
Ok bool `json:"ok"`
}
func (self *listDatabasesCommand) AsRunnable() interface{} {
return "listDatabases"
}
|