From f3875e13c7a6675aa980c29580daae42a32eb97f Mon Sep 17 00:00:00 2001 From: Kiran Kamineni Date: Fri, 29 Mar 2019 16:07:47 -0700 Subject: Make profile key explicit Using profilename instead of name in the db key protects it from getting overwritten by anything else that might use name as a key. Using explicit key names makes sure that we don't have to add bson structure tags in the code. Issue-ID: MULTICLOUD-558 Change-Id: I9bd6f757496af22d8662b0d114f0ef7d33a5784a Signed-off-by: Kiran Kamineni --- src/k8splugin/internal/rb/profile_test.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/k8splugin/internal/rb/profile_test.go') diff --git a/src/k8splugin/internal/rb/profile_test.go b/src/k8splugin/internal/rb/profile_test.go index 5d41b019..856e139b 100644 --- a/src/k8splugin/internal/rb/profile_test.go +++ b/src/k8splugin/internal/rb/profile_test.go @@ -39,7 +39,7 @@ func TestCreateProfile(t *testing.T) { { label: "Create Resource Bundle Profile", inp: Profile{ - Name: "testprofile1", + ProfileName: "testprofile1", ReleaseName: "testprofilereleasename", Namespace: "testnamespace", KubernetesVersion: "1.12.3", @@ -47,7 +47,7 @@ func TestCreateProfile(t *testing.T) { RBVersion: "v1", }, expected: Profile{ - Name: "testprofile1", + ProfileName: "testprofile1", ReleaseName: "testprofilereleasename", Namespace: "testnamespace", KubernetesVersion: "1.12.3", @@ -70,7 +70,7 @@ func TestCreateProfile(t *testing.T) { { label: "Create Resource Bundle Profile With Non-Existing Definition", inp: Profile{ - Name: "testprofile1", + ProfileName: "testprofile1", ReleaseName: "testprofilereleasename", Namespace: "testnamespace", KubernetesVersion: "1.12.3", @@ -136,7 +136,7 @@ func TestGetProfile(t *testing.T) { rbversion: "v1", prname: "testprofile1", expected: Profile{ - Name: "testprofile1", + ProfileName: "testprofile1", ReleaseName: "testprofilereleasename", Namespace: "testnamespace", KubernetesVersion: "1.12.3", @@ -146,7 +146,7 @@ func TestGetProfile(t *testing.T) { expectedError: "", mockdb: &db.MockDB{ Items: map[string]map[string][]byte{ - ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", Name: "testprofile1"}.String(): { + ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", ProfileName: "testprofile1"}.String(): { "metadata": []byte( "{\"profile-name\":\"testprofile1\"," + "\"release-name\":\"testprofilereleasename\"," + @@ -266,7 +266,7 @@ func TestUploadProfile(t *testing.T) { }, mockdb: &db.MockDB{ Items: map[string]map[string][]byte{ - ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", Name: "testprofile1"}.String(): { + ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", ProfileName: "testprofile1"}.String(): { "metadata": []byte( "{\"profile-name\":\"testprofile1\"," + "\"release-name\":\"testprofilereleasename\"," + @@ -307,7 +307,7 @@ func TestUploadProfile(t *testing.T) { }, mockdb: &db.MockDB{ Items: map[string]map[string][]byte{ - ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", Name: "testprofile2"}.String(): { + ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", ProfileName: "testprofile2"}.String(): { "metadata": []byte( "{\"profile-name\":\"testprofile1\"," + "\"release-name\":\"testprofilereleasename\"," + @@ -331,7 +331,7 @@ func TestUploadProfile(t *testing.T) { }, mockdb: &db.MockDB{ Items: map[string]map[string][]byte{ - ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", Name: "testprofile1"}.String(): { + ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", ProfileName: "testprofile1"}.String(): { "metadata": []byte( "{\"profile-name\":\"testprofile1\"," + "\"release-name\":\"testprofilereleasename\"," + @@ -426,7 +426,7 @@ func TestDownloadProfile(t *testing.T) { }, mockdb: &db.MockDB{ Items: map[string]map[string][]byte{ - ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", Name: "testprofile1"}.String(): { + ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", ProfileName: "testprofile1"}.String(): { "metadata": []byte( "{\"profile-name\":\"testprofile1\"," + "\"release-name\":\"testprofilereleasename\"," + @@ -450,7 +450,7 @@ func TestDownloadProfile(t *testing.T) { expectedError: "Invalid Profile Name provided", mockdb: &db.MockDB{ Items: map[string]map[string][]byte{ - ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", Name: "testprofile2"}.String(): { + ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", ProfileName: "testprofile2"}.String(): { "metadata": []byte( "{\"profile-name\":\"testprofile1\"," + "\"release-name\":\"testprofilereleasename\"," + @@ -513,7 +513,7 @@ func TestResolveProfile(t *testing.T) { mockdb: &db.MockDB{ Items: map[string]map[string][]byte{ ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", - Name: "profile1"}.String(): { + ProfileName: "profile1"}.String(): { "metadata": []byte( "{\"profile-name\":\"profile1\"," + "\"release-name\":\"testprofilereleasename\"," + -- cgit 1.2.3-korg