diff options
author | Ritu Sood <Ritu.Sood@intel.com> | 2020-04-23 21:40:06 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-04-23 21:40:06 +0000 |
commit | 334322f5995394dfa6a948101064634eaaf5f0b5 (patch) | |
tree | e30d1625633de0e2ffb68fe195be75a2873a5edf /src/orchestrator/api/controllerhandler_test.go | |
parent | b54eda4919487b700554a27cb46b6e6b465ad180 (diff) | |
parent | 0b59486c82a9786c85438f6352636b19b83e1021 (diff) |
Merge "Controller API support"
Diffstat (limited to 'src/orchestrator/api/controllerhandler_test.go')
-rw-r--r-- | src/orchestrator/api/controllerhandler_test.go | 57 |
1 files changed, 42 insertions, 15 deletions
diff --git a/src/orchestrator/api/controllerhandler_test.go b/src/orchestrator/api/controllerhandler_test.go index 3c543cb8..a2f93ea7 100644 --- a/src/orchestrator/api/controllerhandler_test.go +++ b/src/orchestrator/api/controllerhandler_test.go @@ -40,7 +40,7 @@ type mockControllerManager struct { Err error } -func (m *mockControllerManager) CreateController(inp moduleLib.Controller) (moduleLib.Controller, error) { +func (m *mockControllerManager) CreateController(inp moduleLib.Controller, mayExist bool) (moduleLib.Controller, error) { if m.Err != nil { return moduleLib.Controller{}, m.Err } @@ -56,6 +56,14 @@ func (m *mockControllerManager) GetController(name string) (moduleLib.Controller return m.Items[0], nil } +func (m *mockControllerManager) GetControllers() ([]moduleLib.Controller, error) { + if m.Err != nil { + return []moduleLib.Controller{}, m.Err + } + + return m.Items, nil +} + func (m *mockControllerManager) DeleteController(name string) error { return m.Err } @@ -77,22 +85,33 @@ func TestControllerCreateHandler(t *testing.T) { label: "Create Controller", expectedCode: http.StatusCreated, reader: bytes.NewBuffer([]byte(`{ - "name":"testController", + "metadata": { + "name":"testController" + }, + "spec": { "ip-address":"10.188.234.1", - "port":8080 + "port":8080 } }`)), expected: moduleLib.Controller{ - Name: "testController", - Host: "10.188.234.1", - Port: 8080, + Metadata: moduleLib.Metadata{ + Name: "testController", + }, + Spec: moduleLib.ControllerSpec{ + Host: "10.188.234.1", + Port: 8080, + }, }, controllerClient: &mockControllerManager{ //Items that will be returned by the mocked Client Items: []moduleLib.Controller{ { - Name: "testController", - Host: "10.188.234.1", - Port: 8080, + Metadata: moduleLib.Metadata{ + Name: "testController", + }, + Spec: moduleLib.ControllerSpec{ + Host: "10.188.234.1", + Port: 8080, + }, }, }, }, @@ -144,17 +163,25 @@ func TestControllerGetHandler(t *testing.T) { label: "Get Controller", expectedCode: http.StatusOK, expected: moduleLib.Controller{ - Name: "testController", - Host: "10.188.234.1", - Port: 8080, + Metadata: moduleLib.Metadata{ + Name: "testController", + }, + Spec: moduleLib.ControllerSpec{ + Host: "10.188.234.1", + Port: 8080, + }, }, name: "testController", controllerClient: &mockControllerManager{ Items: []moduleLib.Controller{ { - Name: "testController", - Host: "10.188.234.1", - Port: 8080, + Metadata: moduleLib.Metadata{ + Name: "testController", + }, + Spec: moduleLib.ControllerSpec{ + Host: "10.188.234.1", + Port: 8080, + }, }, }, }, |