Skip to content

Commit 4c99f9e

Browse files
Merge pull request #11 from timvaillancourt/add_codecov_badge
Add codecov badge to README.md
2 parents 03a5d80 + b334974 commit 4c99f9e

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
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

67
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
78

config/manager_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
}

0 commit comments

Comments
 (0)