Skip to content

Commit

Permalink
Handle error from json.Unmarshal, fix test and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
calvn committed Dec 4, 2017
1 parent 8807a27 commit 24f37a2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion plugins/database/mongodb/connection_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ func (c *mongoDBConnectionProducer) Connection() (interface{}, error) {
}

var concern writeConcern
json.Unmarshal([]byte(input), &concern)
err = json.Unmarshal([]byte(input), &concern)
if err != nil {
return nil, err
}

c.session.SetSafe(&mgo.Safe{
W: concern.W,
Expand Down
2 changes: 1 addition & 1 deletion plugins/database/mongodb/mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

const testMongoDBRole = `{ "db": "admin", "roles": [ { "role": "readWrite" } ] }`

const testMongoDBWriteConcern = `{ "w": "majority", "wtimeout": 5000 }`
const testMongoDBWriteConcern = `{ "wmode": "majority", "wtimeout": 5000 }`

func prepareMongoDBTestContainer(t *testing.T) (cleanup func(), retURL string) {
if os.Getenv("MONGODB_URL") != "" {
Expand Down
2 changes: 1 addition & 1 deletion website/source/api/secret/databases/mongodb.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ has a number of parameters to further configure a connection.
"plugin_name": "mongodb-database-plugin",
"allowed_roles": "readonly",
"connection_url": "mongodb://admin:[email protected]:27017/admin?ssl=true",
"write_concern": "{ \"w\": \"majority\", \"wtimeout\": 5000 }"
"write_concern": "{ \"wmode\": \"majority\", \"wtimeout\": 5000 }"
}
```

Expand Down

0 comments on commit 24f37a2

Please sign in to comment.