From 37aed9b7a0db62b9931d89c614ff6291cc4608cc Mon Sep 17 00:00:00 2001 From: Rajamohan Raj Date: Mon, 24 Feb 2020 21:59:44 +0000 Subject: Implemented AppIntents and GenPlaceIntents Implemented the routes for creating, getting, and deleting generic placement intents and App intents. Issue-ID: MULTICLOUD-875 Signed-off-by: Rajamohan Raj Change-Id: Iecb11c442958a43a517772e066de45213e3d7030 --- src/orchestrator/pkg/infra/db/mock.go | 21 ++++++++++++++++++++- src/orchestrator/pkg/infra/db/mongo_test.go | 3 +-- 2 files changed, 21 insertions(+), 3 deletions(-) (limited to 'src/orchestrator/pkg/infra') diff --git a/src/orchestrator/pkg/infra/db/mock.go b/src/orchestrator/pkg/infra/db/mock.go index 6b46a524..79366d10 100644 --- a/src/orchestrator/pkg/infra/db/mock.go +++ b/src/orchestrator/pkg/infra/db/mock.go @@ -45,6 +45,10 @@ func (m *MockDB) Create(table string, key Key, tag string, data interface{}) err return m.Err } +func (m *MockDB) Insert(table string, key Key, query interface{}, tag string, data interface{}) error { + return m.Err +} + func (m *MockDB) Update(table string, key Key, tag string, data interface{}) error { return m.Err } @@ -73,7 +77,22 @@ func (m *MockDB) Read(table string, key Key, tag string) ([]byte, error) { return nil, m.Err } +func (m *MockDB) Find(table string, key Key, tag string) ([][]byte, error) { + if m.Err != nil { + return nil, m.Err + } + + str := fmt.Sprintf("%v", key) + for k, v := range m.Items { + if k == str { + + return [][]byte{v[tag]}, nil + } + } + + return nil, m.Err +} + func (m *MockDB) Delete(table string, key Key, tag string) error { return m.Err } - diff --git a/src/orchestrator/pkg/infra/db/mongo_test.go b/src/orchestrator/pkg/infra/db/mongo_test.go index d506dbda..9f813ca4 100644 --- a/src/orchestrator/pkg/infra/db/mongo_test.go +++ b/src/orchestrator/pkg/infra/db/mongo_test.go @@ -76,7 +76,7 @@ func (c *mockCollection) DeleteMany(ctx context.Context, filter interface{}, func (c *mockCollection) UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error) { - return nil, c.Err + return nil, c.Err } func TestCreate(t *testing.T) { @@ -463,4 +463,3 @@ func TestDelete(t *testing.T) { }) } } - -- cgit 1.2.3-korg