summaryrefslogtreecommitdiffstats
path: root/src/k8splugin/rb
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2019-01-23 12:09:42 -0800
committerKiran Kamineni <kiran.k.kamineni@intel.com>2019-01-23 12:09:46 -0800
commit704d7c52983cd935b48d4eb38108c758c7b6c67d (patch)
treef43035dc95795708c743a8e57d79c2a2d6876168 /src/k8splugin/rb
parentf26259e651ee0be263a3398d2d0ca0eb27c8995c (diff)
Add support for tags in the mockdb
Add support for tags in mockdb. Needed for supporting unit tests where a method does multiple db calls using same uuid but different tags. Eg: Download methods Issue-ID: MULTICLOUD-455 Change-Id: I4eff8eeb00eac630205e4e186981a53a573b61fa Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
Diffstat (limited to 'src/k8splugin/rb')
-rw-r--r--src/k8splugin/rb/definition_test.go82
-rw-r--r--src/k8splugin/rb/profile_test.go94
2 files changed, 100 insertions, 76 deletions
diff --git a/src/k8splugin/rb/definition_test.go b/src/k8splugin/rb/definition_test.go
index b3603136..f1ec18ee 100644
--- a/src/k8splugin/rb/definition_test.go
+++ b/src/k8splugin/rb/definition_test.go
@@ -110,17 +110,21 @@ func TestListDefinition(t *testing.T) {
},
expectedError: "",
mockdb: &db.MockDB{
- Items: map[string][]byte{
- "123e4567-e89b-12d3-a456-426655440000": []byte(
- "{\"name\":\"testresourcebundle\"," +
- "\"description\":\"testresourcebundle\"," +
- "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
- "\"service-type\":\"firewall\"}"),
- "123e4567-e89b-12d3-a456-426655441111": []byte(
- "{\"name\":\"testresourcebundle2\"," +
- "\"description\":\"testresourcebundle2\"," +
- "\"uuid\":\"123e4567-e89b-12d3-a456-426655441111\"," +
- "\"service-type\":\"dns\"}"),
+ Items: map[string]map[string][]byte{
+ "123e4567-e89b-12d3-a456-426655440000": {
+ "metadata": []byte(
+ "{\"name\":\"testresourcebundle\"," +
+ "\"description\":\"testresourcebundle\"," +
+ "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
+ "\"service-type\":\"firewall\"}"),
+ },
+ "123e4567-e89b-12d3-a456-426655441111": {
+ "metadata": []byte(
+ "{\"name\":\"testresourcebundle2\"," +
+ "\"description\":\"testresourcebundle2\"," +
+ "\"uuid\":\"123e4567-e89b-12d3-a456-426655441111\"," +
+ "\"service-type\":\"dns\"}"),
+ },
},
},
},
@@ -186,12 +190,14 @@ func TestGetDefinition(t *testing.T) {
},
expectedError: "",
mockdb: &db.MockDB{
- Items: map[string][]byte{
- "123e4567-e89b-12d3-a456-426655440000": []byte(
- "{\"name\":\"testresourcebundle\"," +
- "\"description\":\"testresourcebundle\"," +
- "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
- "\"service-type\":\"firewall\"}"),
+ Items: map[string]map[string][]byte{
+ "123e4567-e89b-12d3-a456-426655440000": {
+ "metadata": []byte(
+ "{\"name\":\"testresourcebundle\"," +
+ "\"description\":\"testresourcebundle\"," +
+ "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
+ "\"service-type\":\"firewall\"}"),
+ },
},
},
},
@@ -298,12 +304,14 @@ func TestUploadDefinition(t *testing.T) {
0x4a, 0xf9, 0x00, 0x28, 0x00, 0x00,
},
mockdb: &db.MockDB{
- Items: map[string][]byte{
- "123e4567-e89b-12d3-a456-426655440000": []byte(
- "{\"name\":\"testresourcebundle\"," +
- "\"description\":\"testresourcebundle\"," +
- "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
- "\"service-type\":\"firewall\"}"),
+ Items: map[string]map[string][]byte{
+ "123e4567-e89b-12d3-a456-426655440000": {
+ "metadata": []byte(
+ "{\"name\":\"testresourcebundle\"," +
+ "\"description\":\"testresourcebundle\"," +
+ "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
+ "\"service-type\":\"firewall\"}"),
+ },
},
},
},
@@ -333,12 +341,14 @@ func TestUploadDefinition(t *testing.T) {
0x4a, 0xf9, 0x00, 0x28, 0x00, 0x00,
},
mockdb: &db.MockDB{
- Items: map[string][]byte{
- "123e4567-e89b-12d3-a456-426655441111": []byte(
- "{\"name\":\"testresourcebundle\"," +
- "\"description\":\"testresourcebundle\"," +
- "\"uuid\":\"123e4567-e89b-12d3-a456-426655441111\"," +
- "\"service-type\":\"firewall\"}"),
+ Items: map[string]map[string][]byte{
+ "123e4567-e89b-12d3-a456-426655441111": {
+ "metadata": []byte(
+ "{\"name\":\"testresourcebundle\"," +
+ "\"description\":\"testresourcebundle\"," +
+ "\"uuid\":\"123e4567-e89b-12d3-a456-426655441111\"," +
+ "\"service-type\":\"firewall\"}"),
+ },
},
},
},
@@ -351,12 +361,14 @@ func TestUploadDefinition(t *testing.T) {
0x00, 0xff, 0xf2, 0x48, 0xcd,
},
mockdb: &db.MockDB{
- Items: map[string][]byte{
- "123e4567-e89b-12d3-a456-426655440000": []byte(
- "{\"name\":\"testresourcebundle\"," +
- "\"description\":\"testresourcebundle\"," +
- "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
- "\"service-type\":\"firewall\"}"),
+ Items: map[string]map[string][]byte{
+ "123e4567-e89b-12d3-a456-426655440000": {
+ "metadata": []byte(
+ "{\"name\":\"testresourcebundle\"," +
+ "\"description\":\"testresourcebundle\"," +
+ "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
+ "\"service-type\":\"firewall\"}"),
+ },
},
},
},
diff --git a/src/k8splugin/rb/profile_test.go b/src/k8splugin/rb/profile_test.go
index 26b9747c..2540d3ca 100644
--- a/src/k8splugin/rb/profile_test.go
+++ b/src/k8splugin/rb/profile_test.go
@@ -54,12 +54,14 @@ func TestCreateProfile(t *testing.T) {
},
expectedError: "",
mockdb: &db.MockDB{
- Items: map[string][]byte{
- "abcde123-e89b-8888-a456-986655447236": []byte(
- "{\"name\":\"testresourcebundle\"," +
- "\"namespace\":\"default\"," +
- "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
- "\"kubernetesversion\":\"1.12.3\"}"),
+ Items: map[string]map[string][]byte{
+ "abcde123-e89b-8888-a456-986655447236": {
+ "metadata": []byte(
+ "{\"name\":\"testresourcebundle\"," +
+ "\"namespace\":\"default\"," +
+ "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
+ "\"kubernetesversion\":\"1.12.3\"}"),
+ },
},
},
},
@@ -115,13 +117,15 @@ func TestListProfiles(t *testing.T) {
},
expectedError: "",
mockdb: &db.MockDB{
- Items: map[string][]byte{
- "123e4567-e89b-12d3-a456-426655440000": []byte(
- "{\"name\":\"testresourcebundle\"," +
- "\"namespace\":\"default\"," +
- "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
- "\"rbdid\":\"abcde123-e89b-8888-a456-986655447236\"," +
- "\"kubernetesversion\":\"1.12.3\"}"),
+ Items: map[string]map[string][]byte{
+ "123e4567-e89b-12d3-a456-426655440000": {
+ "metadata": []byte(
+ "{\"name\":\"testresourcebundle\"," +
+ "\"namespace\":\"default\"," +
+ "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
+ "\"rbdid\":\"abcde123-e89b-8888-a456-986655447236\"," +
+ "\"kubernetesversion\":\"1.12.3\"}"),
+ },
},
},
},
@@ -188,13 +192,15 @@ func TestGetProfile(t *testing.T) {
},
expectedError: "",
mockdb: &db.MockDB{
- Items: map[string][]byte{
- "123e4567-e89b-12d3-a456-426655440000": []byte(
- "{\"name\":\"testresourcebundle\"," +
- "\"namespace\":\"default\"," +
- "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
- "\"rbdid\":\"abcde123-e89b-8888-a456-986655447236\"," +
- "\"kubernetesversion\":\"1.12.3\"}"),
+ Items: map[string]map[string][]byte{
+ "123e4567-e89b-12d3-a456-426655440000": {
+ "metadata": []byte(
+ "{\"name\":\"testresourcebundle\"," +
+ "\"namespace\":\"default\"," +
+ "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
+ "\"rbdid\":\"abcde123-e89b-8888-a456-986655447236\"," +
+ "\"kubernetesversion\":\"1.12.3\"}"),
+ },
},
},
},
@@ -301,13 +307,15 @@ func TestUploadProfile(t *testing.T) {
0x4a, 0xf9, 0x00, 0x28, 0x00, 0x00,
},
mockdb: &db.MockDB{
- Items: map[string][]byte{
- "123e4567-e89b-12d3-a456-426655440000": []byte(
- "{\"name\":\"testresourcebundle\"," +
- "\"namespace\":\"default\"," +
- "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
- "\"rbdid\":\"abcde123-e89b-8888-a456-986655447236\"," +
- "\"kubernetesversion\":\"1.12.3\"}"),
+ Items: map[string]map[string][]byte{
+ "123e4567-e89b-12d3-a456-426655440000": {
+ "metadata": []byte(
+ "{\"name\":\"testresourcebundle\"," +
+ "\"namespace\":\"default\"," +
+ "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
+ "\"rbdid\":\"abcde123-e89b-8888-a456-986655447236\"," +
+ "\"kubernetesversion\":\"1.12.3\"}"),
+ },
},
},
},
@@ -337,13 +345,15 @@ func TestUploadProfile(t *testing.T) {
0x4a, 0xf9, 0x00, 0x28, 0x00, 0x00,
},
mockdb: &db.MockDB{
- Items: map[string][]byte{
- "123e4567-e89b-12d3-a456-426655441111": []byte(
- "{\"name\":\"testresourcebundle\"," +
- "\"namespace\":\"default\"," +
- "\"uuid\":\"123e4567-e89b-12d3-a456-426655441111\"," +
- "\"rbdid\":\"abcde123-e89b-8888-a456-986655447236\"," +
- "\"kubernetesversion\":\"1.12.3\"}"),
+ Items: map[string]map[string][]byte{
+ "123e4567-e89b-12d3-a456-426655441111": {
+ "metadata": []byte(
+ "{\"name\":\"testresourcebundle\"," +
+ "\"namespace\":\"default\"," +
+ "\"uuid\":\"123e4567-e89b-12d3-a456-426655441111\"," +
+ "\"rbdid\":\"abcde123-e89b-8888-a456-986655447236\"," +
+ "\"kubernetesversion\":\"1.12.3\"}"),
+ },
},
},
},
@@ -356,13 +366,15 @@ func TestUploadProfile(t *testing.T) {
0x00, 0xff, 0xf2, 0x48, 0xcd,
},
mockdb: &db.MockDB{
- Items: map[string][]byte{
- "123e4567-e89b-12d3-a456-426655440000": []byte(
- "{\"name\":\"testresourcebundle\"," +
- "\"namespace\":\"default\"," +
- "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
- "\"rbdid\":\"abcde123-e89b-8888-a456-986655447236\"," +
- "\"kubernetesversion\":\"1.12.3\"}"),
+ Items: map[string]map[string][]byte{
+ "123e4567-e89b-12d3-a456-426655440000": {
+ "metadata": []byte(
+ "{\"name\":\"testresourcebundle\"," +
+ "\"namespace\":\"default\"," +
+ "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
+ "\"rbdid\":\"abcde123-e89b-8888-a456-986655447236\"," +
+ "\"kubernetesversion\":\"1.12.3\"}"),
+ },
},
},
},