From 9ed505750dd640f5baa1cc8d38efe1b6be6891f8 Mon Sep 17 00:00:00 2001 From: Kiran Kamineni Date: Fri, 20 Dec 2019 13:48:40 -0800 Subject: 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 --- src/k8splugin/internal/db/testing.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/k8splugin/internal') 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 } -- cgit 1.2.3-korg