summaryrefslogtreecommitdiffstats
path: root/src/k8splugin
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2019-12-20 13:48:40 -0800
committerKiran Kamineni <kiran.k.kamineni@intel.com>2019-12-20 13:48:43 -0800
commit9ed505750dd640f5baa1cc8d38efe1b6be6891f8 (patch)
treeb4b621b436b004491755fb6a2276a1dac87b4c5c /src/k8splugin
parent20b0ff063a92e6d4a5ecaf621e527c09ff1e5515 (diff)
Update write to store data
This is to support multiple calls that might hit the database such as creation of profile within another definition create. Issue-ID: MULTICLOUD-666 Change-Id: I2cb8e705eaa5f825936156d7c626f16f373e28c0 Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
Diffstat (limited to 'src/k8splugin')
-rw-r--r--src/k8splugin/internal/db/testing.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/k8splugin/internal/db/testing.go b/src/k8splugin/internal/db/testing.go
index 5f69dcb4..9a427e03 100644
--- a/src/k8splugin/internal/db/testing.go
+++ b/src/k8splugin/internal/db/testing.go
@@ -15,6 +15,7 @@ package db
import (
"encoding/json"
+
pkgerrors "github.com/pkg/errors"
)
@@ -40,6 +41,19 @@ func (m *MockDB) HealthCheck() error {
}
func (m *MockDB) Create(table string, key Key, tag string, data interface{}) error {
+ djs, err := json.Marshal(data)
+ if err != nil {
+ return err
+ }
+
+ d := make(map[string][]byte)
+ d[tag] = djs
+
+ if m.Items == nil {
+ m.Items = make(map[string]map[string][]byte)
+ }
+ m.Items[key.String()] = d
+
return m.Err
}