diff options
author | Ritu Sood <Ritu.Sood@intel.com> | 2020-03-06 19:38:38 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-03-06 19:38:38 +0000 |
commit | 3b57e9d29764c3c8ee2d398990ac2aafda1eb2b9 (patch) | |
tree | f31b3a3cf89f510cc896844879b20be7d557b17f /src/orchestrator/pkg/infra/db | |
parent | 65f9bc3b632a012429cd94aa2e6160b44fe633a7 (diff) | |
parent | 59ead086a9fbd61cad2187f196b1176c20f98691 (diff) |
Merge "Change DB Name to accept variable"
Diffstat (limited to 'src/orchestrator/pkg/infra/db')
-rw-r--r-- | src/orchestrator/pkg/infra/db/store.go | 8 | ||||
-rw-r--r-- | src/orchestrator/pkg/infra/db/store_test.go | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/orchestrator/pkg/infra/db/store.go b/src/orchestrator/pkg/infra/db/store.go index 0cf3ef65..f8cb4466 100644 --- a/src/orchestrator/pkg/infra/db/store.go +++ b/src/orchestrator/pkg/infra/db/store.go @@ -64,12 +64,12 @@ type Store interface { } // CreateDBClient creates the DB client -func createDBClient(dbType string) error { +func createDBClient(dbType string, dbName string) error { var err error switch dbType { case "mongo": // create a mongodb database with orchestrator as the name - DBconn, err = NewMongoStore("orchestrator", nil) + DBconn, err = NewMongoStore(dbName, nil) default: return pkgerrors.New(dbType + "DB not supported") } @@ -96,8 +96,8 @@ func DeSerialize(str string, v interface{}) error { // InitializeDatabaseConnection sets up the connection to the // configured database to allow the application to talk to it. -func InitializeDatabaseConnection() error { - err := createDBClient(config.GetConfiguration().DatabaseType) +func InitializeDatabaseConnection(dbName string) error { + err := createDBClient(config.GetConfiguration().DatabaseType, dbName) if err != nil { return pkgerrors.Cause(err) } diff --git a/src/orchestrator/pkg/infra/db/store_test.go b/src/orchestrator/pkg/infra/db/store_test.go index 42a41787..fb23e232 100644 --- a/src/orchestrator/pkg/infra/db/store_test.go +++ b/src/orchestrator/pkg/infra/db/store_test.go @@ -23,7 +23,7 @@ func TestCreateDBClient(t *testing.T) { t.Run("Successfully create DB client", func(t *testing.T) { expected := &MongoStore{} - err := createDBClient("mongo") + err := createDBClient("mongo", "testdb") if err != nil { t.Fatalf("CreateDBClient returned an error (%s)", err) } @@ -32,7 +32,7 @@ func TestCreateDBClient(t *testing.T) { } }) t.Run("Fail to create client for unsupported DB", func(t *testing.T) { - err := createDBClient("fakeDB") + err := createDBClient("fakeDB", "testdb2") if err == nil { t.Fatal("CreateDBClient didn't return an error") } |