summaryrefslogtreecommitdiffstats
path: root/src/orchestrator/pkg/infra
diff options
context:
space:
mode:
authorRajamohan Raj <rajamohan.raj@intel.com>2020-02-24 21:59:44 +0000
committerRajamohan Raj <rajamohan.raj@intel.com>2020-03-03 23:08:13 +0000
commit37aed9b7a0db62b9931d89c614ff6291cc4608cc (patch)
tree51021b0776978d77c4a1cad455be582a4dafa894 /src/orchestrator/pkg/infra
parent7b566f2875230e15f79a6549b17240e767cc98f1 (diff)
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 <rajamohan.raj@intel.com> Change-Id: Iecb11c442958a43a517772e066de45213e3d7030
Diffstat (limited to 'src/orchestrator/pkg/infra')
-rw-r--r--src/orchestrator/pkg/infra/db/mock.go21
-rw-r--r--src/orchestrator/pkg/infra/db/mongo_test.go3
2 files changed, 21 insertions, 3 deletions
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) {
})
}
}
-