From: Kiran Kamineni Date: Fri, 20 Dec 2019 21:48:40 +0000 (-0800) Subject: Update write to store data X-Git-Tag: 0.6.0~87 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F70%2F99870%2F1;p=multicloud%2Fk8s.git 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 --- 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 }