File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 22[ ![ ] ( https://godoc.org/github.com/timvaillancourt/go-mongodb-replset?status.svg )] ( http://godoc.org/github.com/timvaillancourt/go-mongodb-replset )
33[ ![ Build Status] ( https://travis-ci.org/timvaillancourt/go-mongodb-replset.svg?branch=master )] ( https://travis-ci.org/timvaillancourt/go-mongodb-replset )
44[ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/timvaillancourt/go-mongodb-replset )] ( https://goreportcard.com/report/github.com/timvaillancourt/go-mongodb-replset )
5+ [ ![ codecov] ( https://codecov.io/gh/timvaillancourt/go-mongodb-replset/branch/master/graph/badge.svg )] ( https://codecov.io/gh/timvaillancourt/go-mongodb-replset )
56
67A package of golang structs for reading/modifying MongoDB replset config and state. The structs are to unmarshal the output of the [ 'replSetGetConfig'] ( https://docs.mongodb.com/manual/reference/command/replSetGetConfig/ ) and [ 'replSetGetStatus'] ( https://docs.mongodb.com/manual/reference/command/replSetGetStatus/ ) server commands
78
Original file line number Diff line number Diff line change 1+ package config
2+
3+ import (
4+ "testing"
5+
6+ "github.com/stretchr/testify/assert"
7+ "gopkg.in/mgo.v2"
8+ )
9+
10+ var (
11+ testManager * ConfigManager
12+ )
13+
14+ func TestNewManager (t * testing.T ) {
15+ session , err := mgo .Dial ("mongodb://localhost:65217" )
16+ if err != nil {
17+ assert .FailNow (t , "cannot get session" )
18+ }
19+ if session .Ping () != nil {
20+ assert .FailNow (t , "cannot ping session" )
21+ }
22+
23+ testManager = New (session )
24+ assert .Equal (t , session , testManager .session , "testManager.session is incorrect" )
25+ assert .False (t , testManager .initiated , "testManager.initiated should be false" )
26+ assert .Nil (t , testManager .config , "testManager.config should be nil" )
27+ }
28+
29+ func TestManagerGetNil (t * testing.T ) {
30+ assert .Nil (t , testManager .Get (), "manager.Get() returned unexpected data" )
31+ }
32+
33+ func TestManagerLoad (t * testing.T ) {
34+ err := testManager .Load ()
35+ if err != nil {
36+ assert .FailNow (t , "manager.Load() returned error" )
37+ }
38+ assert .True (t , testManager .initiated , "manager.initiated is not true" )
39+ assert .NotNil (t , testManager .config , "manager.config is nil" )
40+ }
You can’t perform that action at this time.
0 commit comments