Use WeakDecode to decode the initialize values (#2871)

This commit is contained in:
Brian Kassouf
2017-06-14 18:59:27 -07:00
committed by GitHub
parent 4dea784fac
commit b9871fc9ad
7 changed files with 52 additions and 4 deletions

View File

@@ -99,6 +99,19 @@ func TestCassandra_Initialize(t *testing.T) {
if err != nil {
t.Fatalf("err: %s", err)
}
// test a string protocol
connectionDetails = map[string]interface{}{
"hosts": connURL,
"username": "cassandra",
"password": "cassandra",
"protocol_version": "4",
}
err = db.Initialize(connectionDetails, true)
if err != nil {
t.Fatalf("err: %s", err)
}
}
func TestCassandra_CreateUser(t *testing.T) {

View File

@@ -46,7 +46,7 @@ func (c *cassandraConnectionProducer) Initialize(conf map[string]interface{}, ve
c.Lock()
defer c.Unlock()
err := mapstructure.Decode(conf, c)
err := mapstructure.WeakDecode(conf, c)
if err != nil {
return err
}

View File

@@ -33,7 +33,7 @@ func (c *mongoDBConnectionProducer) Initialize(conf map[string]interface{}, veri
c.Lock()
defer c.Unlock()
err := mapstructure.Decode(conf, c)
err := mapstructure.WeakDecode(conf, c)
if err != nil {
return err
}

View File

@@ -44,6 +44,17 @@ func TestMSSQL_Initialize(t *testing.T) {
if err != nil {
t.Fatalf("err: %s", err)
}
// Test decoding a string value for max_open_connections
connectionDetails = map[string]interface{}{
"connection_url": connURL,
"max_open_connections": "5",
}
err = db.Initialize(connectionDetails, true)
if err != nil {
t.Fatalf("err: %s", err)
}
}
func TestMSSQL_CreateUser(t *testing.T) {

View File

@@ -84,6 +84,17 @@ func TestMySQL_Initialize(t *testing.T) {
if err != nil {
t.Fatalf("err: %s", err)
}
// Test decoding a string value for max_open_connections
connectionDetails = map[string]interface{}{
"connection_url": connURL,
"max_open_connections": "5",
}
err = db.Initialize(connectionDetails, true)
if err != nil {
t.Fatalf("err: %s", err)
}
}
func TestMySQL_CreateUser(t *testing.T) {

View File

@@ -63,7 +63,8 @@ func TestPostgreSQL_Initialize(t *testing.T) {
defer cleanup()
connectionDetails := map[string]interface{}{
"connection_url": connURL,
"connection_url": connURL,
"max_open_connections": 5,
}
dbRaw, _ := New()
@@ -84,6 +85,18 @@ func TestPostgreSQL_Initialize(t *testing.T) {
if err != nil {
t.Fatalf("err: %s", err)
}
// Test decoding a string value for max_open_connections
connectionDetails = map[string]interface{}{
"connection_url": connURL,
"max_open_connections": "5",
}
err = db.Initialize(connectionDetails, true)
if err != nil {
t.Fatalf("err: %s", err)
}
}
func TestPostgreSQL_CreateUser(t *testing.T) {

View File

@@ -33,7 +33,7 @@ func (c *SQLConnectionProducer) Initialize(conf map[string]interface{}, verifyCo
c.Lock()
defer c.Unlock()
err := mapstructure.Decode(conf, c)
err := mapstructure.WeakDecode(conf, c)
if err != nil {
return err
}