Update New() func signature and its references

This commit is contained in:
Calvin Leung Huang 2017-04-27 11:07:52 -04:00
parent 2faa08dfba
commit 230a36c5a1
2 changed files with 15 additions and 8 deletions

View file

@ -24,7 +24,7 @@ type Cassandra struct {
credsutil.CredentialsProducer
}
func New() *Cassandra {
func New() (interface{}, error) {
connProducer := &connutil.CassandraConnectionProducer{}
connProducer.Type = cassandraTypeName
@ -35,14 +35,17 @@ func New() *Cassandra {
CredentialsProducer: credsProducer,
}
return dbType
return dbType, nil
}
// Run instantiates a MySQL object, and runs the RPC server for the plugin
func Run() error {
dbType := New()
dbType, err := New()
if err != nil {
return err
}
dbplugin.NewPluginServer(dbType)
dbplugin.NewPluginServer(dbType.(*Cassandra))
return nil
}

View file

@ -80,7 +80,8 @@ func TestCassandra_Initialize(t *testing.T) {
"protocol_version": 4,
}
db := New()
dbRaw, _ := New()
db := dbRaw.(*Cassandra)
connProducer := db.ConnectionProducer.(*connutil.CassandraConnectionProducer)
err := db.Initialize(connectionDetails, true)
@ -109,7 +110,8 @@ func TestCassandra_CreateUser(t *testing.T) {
"protocol_version": 4,
}
db := New()
dbRaw, _ := New()
db := dbRaw.(*Cassandra)
err := db.Initialize(connectionDetails, true)
if err != nil {
t.Fatalf("err: %s", err)
@ -140,7 +142,8 @@ func TestMyCassandra_RenewUser(t *testing.T) {
"protocol_version": 4,
}
db := New()
dbRaw, _ := New()
db := dbRaw.(*Cassandra)
err := db.Initialize(connectionDetails, true)
if err != nil {
t.Fatalf("err: %s", err)
@ -176,7 +179,8 @@ func TestCassandra_RevokeUser(t *testing.T) {
"protocol_version": 4,
}
db := New()
dbRaw, _ := New()
db := dbRaw.(*Cassandra)
err := db.Initialize(connectionDetails, true)
if err != nil {
t.Fatalf("err: %s", err)