Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[![](https://godoc.org/github.com/timvaillancourt/go-mongodb-replset?status.svg)](http://godoc.org/github.com/timvaillancourt/go-mongodb-replset)
[![Build Status](https://travis-ci.org/timvaillancourt/go-mongodb-replset.svg?branch=master)](https://travis-ci.org/timvaillancourt/go-mongodb-replset)
[![Go Report Card](https://goreportcard.com/badge/github.com/timvaillancourt/go-mongodb-replset)](https://goreportcard.com/report/github.com/timvaillancourt/go-mongodb-replset)
[![codecov](https://codecov.io/gh/timvaillancourt/go-mongodb-replset/branch/master/graph/badge.svg)](https://codecov.io/gh/timvaillancourt/go-mongodb-replset)

A 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

Expand Down
40 changes: 40 additions & 0 deletions config/manager_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package config

import (
"testing"

"github.com/stretchr/testify/assert"
"gopkg.in/mgo.v2"
)

var (
testManager *ConfigManager
)

func TestNewManager(t *testing.T) {
session, err := mgo.Dial("mongodb://localhost:65217")
if err != nil {
assert.FailNow(t, "cannot get session")
}
if session.Ping() != nil {
assert.FailNow(t, "cannot ping session")
}

testManager = New(session)
assert.Equal(t, session, testManager.session, "testManager.session is incorrect")
assert.False(t, testManager.initiated, "testManager.initiated should be false")
assert.Nil(t, testManager.config, "testManager.config should be nil")
}

func TestManagerGetNil(t *testing.T) {
assert.Nil(t, testManager.Get(), "manager.Get() returned unexpected data")
}

func TestManagerLoad(t *testing.T) {
err := testManager.Load()
if err != nil {
assert.FailNow(t, "manager.Load() returned error")
}
assert.True(t, testManager.initiated, "manager.initiated is not true")
assert.NotNil(t, testManager.config, "manager.config is nil")
}