From 144595825be6a6481eec7eb7cd3031bf50ef599e Mon Sep 17 00:00:00 2001 From: Long Nguyen Date: Thu, 1 Aug 2019 11:15:57 +0700 Subject: [PATCH] Add support for couchdb connection string --- util/dbHandle.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/util/dbHandle.go b/util/dbHandle.go index 673ddd8..3d06f19 100644 --- a/util/dbHandle.go +++ b/util/dbHandle.go @@ -17,12 +17,12 @@ type CouchDBHandler struct { CouchDatabase *couchdb.CouchDatabase } -// NewCouchDBHandler returns a new CouchDBHandler and setup database for testing -func NewCouchDBHandler(dbName string, isDrop bool) (*CouchDBHandler, error) { +// NewCouchDBHandlerWithConnection returns a new CouchDBHandler and setup database for testing +func NewCouchDBHandlerWithConnection(dbName string, isDrop bool, connectionString string) (*CouchDBHandler, error) { handler := new(CouchDBHandler) //Create a couchdb instance - couchDBInstance, er := couchdb.CreateCouchInstance(DefaultBaseURL, "", "", 3, 10, time.Second*30, true, &disabled.Provider{}) + couchDBInstance, er := couchdb.CreateCouchInstance(connectionString, "", "", 3, 10, time.Second*30, true, &disabled.Provider{}) if er != nil { return nil, er } @@ -42,6 +42,11 @@ func NewCouchDBHandler(dbName string, isDrop bool) (*CouchDBHandler, error) { return handler, nil } +// NewCouchDBHandler returns a new CouchDBHandler and setup database for testing +func NewCouchDBHandler(dbName string, isDrop bool) (*CouchDBHandler, error) { + return NewCouchDBHandlerWithConnection(dbName, isDrop, DefaultBaseURL) +} + // SaveDocument stores a value in couchDB func (handler *CouchDBHandler) SaveDocument(key string, value []byte) (string, error) { // unmarshal the value param