From 5207bd099a84832a5d7c3333bf540fa8481ce78a Mon Sep 17 00:00:00 2001 From: Kiran Kamineni Date: Thu, 23 May 2019 13:50:50 -0700 Subject: Update broker responses to match spec and SO The broker responses need to match the spec and what SO expects as responses. CREATE_COMPLETE instead of CREATED in both POST and GET DELETE now returns a response body GET by name is now supported Name is an alias for vf_module_id which is expected to be provided as an attribute in sdnc_directives in the original POST request Issue-ID: MULTICLOUD-645 Change-Id: Ifeca755a07298d0a858cbe9e80f9ce654d6d21b8 Signed-off-by: Kiran Kamineni --- src/k8splugin/api/instancehandler_test.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/k8splugin/api/instancehandler_test.go') diff --git a/src/k8splugin/api/instancehandler_test.go b/src/k8splugin/api/instancehandler_test.go index 2e2450ed..dac7db00 100644 --- a/src/k8splugin/api/instancehandler_test.go +++ b/src/k8splugin/api/instancehandler_test.go @@ -58,6 +58,14 @@ func (m *mockInstanceClient) Get(id string) (app.InstanceResponse, error) { return m.items[0], nil } +func (m *mockInstanceClient) Find(rbName string, ver string, profile string, labelKeys map[string]string) ([]app.InstanceResponse, error) { + if m.err != nil { + return nil, m.err + } + + return m.items, nil +} + func (m *mockInstanceClient) Delete(id string) error { return m.err } @@ -104,14 +112,14 @@ func TestInstanceCreateHandler(t *testing.T) { "profile-name": "profile1" }`)), expected: app.InstanceResponse{ - ID: "HaKpys8e", + ID: "HaKpys8e", Request: app.InstanceRequest{ RBName: "test-rbdef", RBVersion: "v1", ProfileName: "profile1", CloudRegion: "region1", }, - Namespace: "testnamespace", + Namespace: "testnamespace", Resources: []helm.KubernetesResource{ { GVK: schema.GroupVersionKind{ @@ -133,14 +141,14 @@ func TestInstanceCreateHandler(t *testing.T) { instClient: &mockInstanceClient{ items: []app.InstanceResponse{ { - ID: "HaKpys8e", + ID: "HaKpys8e", Request: app.InstanceRequest{ RBName: "test-rbdef", RBVersion: "v1", ProfileName: "profile1", CloudRegion: "region1", }, - Namespace: "testnamespace", + Namespace: "testnamespace", Resources: []helm.KubernetesResource{ { GVK: schema.GroupVersionKind{ @@ -207,14 +215,14 @@ func TestInstanceGetHandler(t *testing.T) { input: "HaKpys8e", expectedCode: http.StatusOK, expectedResponse: &app.InstanceResponse{ - ID: "HaKpys8e", + ID: "HaKpys8e", Request: app.InstanceRequest{ RBName: "test-rbdef", RBVersion: "v1", ProfileName: "profile1", CloudRegion: "region1", }, - Namespace: "testnamespace", + Namespace: "testnamespace", Resources: []helm.KubernetesResource{ { GVK: schema.GroupVersionKind{ @@ -235,14 +243,14 @@ func TestInstanceGetHandler(t *testing.T) { instClient: &mockInstanceClient{ items: []app.InstanceResponse{ { - ID: "HaKpys8e", + ID: "HaKpys8e", Request: app.InstanceRequest{ RBName: "test-rbdef", RBVersion: "v1", ProfileName: "profile1", CloudRegion: "region1", }, - Namespace: "testnamespace", + Namespace: "testnamespace", Resources: []helm.KubernetesResource{ { GVK: schema.GroupVersionKind{ -- cgit 1.2.3-korg