From e1c1c794486378cb67dd4682e9fb9b0d2bab26fa Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Mon, 6 Nov 2017 16:53:36 +0100 Subject: [PATCH] Add rpc.dryad.ClientManager interface This interface allows adding an abstraction layer between Dryad's client implementation and usage. It can be used also for using mocked up implementation od Dryad's client for test purposes. The mock implementation of interface is provided in workers package. It is generated using mockgen command: mockgen -package workers \ -destination=workers/dryadclientmanager_mock_test.go \ -write_package_comment=false \ -mock_names ClientManager=MockDryadClientManager \ git.tizen.org/tools/boruta/rpc/dryad ClientManager Change-Id: I7366a0e68a355c98b898fb00ec8efb3c642a725d Signed-off-by: Lukasz Wojciechowski --- rpc/dryad/clientmanager.go | 35 ++++++++++++ workers/dryadclientmanager_mock_test.go | 95 +++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 rpc/dryad/clientmanager.go create mode 100644 workers/dryadclientmanager_mock_test.go diff --git a/rpc/dryad/clientmanager.go b/rpc/dryad/clientmanager.go new file mode 100644 index 0000000..9077d64 --- /dev/null +++ b/rpc/dryad/clientmanager.go @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +// File rpc/dryad/clientmanager.go defines ClientManager interface with API +// for managing client RPC calls to Dryad. + +package dryad + +import ( + "net" + + . "git.tizen.org/tools/boruta" +) + +// ClientManager defines API for managing client RPC calls to Dryad. +type ClientManager interface { + Dryad + // Create creates a new RPC client. + Create(net.IP, int) error + // Close shuts down RPC client connection. + Close() error +} diff --git a/workers/dryadclientmanager_mock_test.go b/workers/dryadclientmanager_mock_test.go new file mode 100644 index 0000000..1d46791 --- /dev/null +++ b/workers/dryadclientmanager_mock_test.go @@ -0,0 +1,95 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: git.tizen.org/tools/boruta/rpc/dryad (interfaces: ClientManager) + +package workers + +import ( + rsa "crypto/rsa" + gomock "github.com/golang/mock/gomock" + net "net" + reflect "reflect" +) + +// MockDryadClientManager is a mock of ClientManager interface +type MockDryadClientManager struct { + ctrl *gomock.Controller + recorder *MockDryadClientManagerMockRecorder +} + +// MockDryadClientManagerMockRecorder is the mock recorder for MockDryadClientManager +type MockDryadClientManagerMockRecorder struct { + mock *MockDryadClientManager +} + +// NewMockDryadClientManager creates a new mock instance +func NewMockDryadClientManager(ctrl *gomock.Controller) *MockDryadClientManager { + mock := &MockDryadClientManager{ctrl: ctrl} + mock.recorder = &MockDryadClientManagerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use +func (m *MockDryadClientManager) EXPECT() *MockDryadClientManagerMockRecorder { + return m.recorder +} + +// Close mocks base method +func (m *MockDryadClientManager) Close() error { + ret := m.ctrl.Call(m, "Close") + ret0, _ := ret[0].(error) + return ret0 +} + +// Close indicates an expected call of Close +func (mr *MockDryadClientManagerMockRecorder) Close() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockDryadClientManager)(nil).Close)) +} + +// Create mocks base method +func (m *MockDryadClientManager) Create(arg0 net.IP, arg1 int) error { + ret := m.ctrl.Call(m, "Create", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// Create indicates an expected call of Create +func (mr *MockDryadClientManagerMockRecorder) Create(arg0, arg1 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockDryadClientManager)(nil).Create), arg0, arg1) +} + +// Healthcheck mocks base method +func (m *MockDryadClientManager) Healthcheck() error { + ret := m.ctrl.Call(m, "Healthcheck") + ret0, _ := ret[0].(error) + return ret0 +} + +// Healthcheck indicates an expected call of Healthcheck +func (mr *MockDryadClientManagerMockRecorder) Healthcheck() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Healthcheck", reflect.TypeOf((*MockDryadClientManager)(nil).Healthcheck)) +} + +// Prepare mocks base method +func (m *MockDryadClientManager) Prepare() (*rsa.PrivateKey, error) { + ret := m.ctrl.Call(m, "Prepare") + ret0, _ := ret[0].(*rsa.PrivateKey) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Prepare indicates an expected call of Prepare +func (mr *MockDryadClientManagerMockRecorder) Prepare() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Prepare", reflect.TypeOf((*MockDryadClientManager)(nil).Prepare)) +} + +// PutInMaintenance mocks base method +func (m *MockDryadClientManager) PutInMaintenance(arg0 string) error { + ret := m.ctrl.Call(m, "PutInMaintenance", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// PutInMaintenance indicates an expected call of PutInMaintenance +func (mr *MockDryadClientManagerMockRecorder) PutInMaintenance(arg0 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PutInMaintenance", reflect.TypeOf((*MockDryadClientManager)(nil).PutInMaintenance), arg0) +} -- 2.7.4