1 diff --git a/src/controller/servicemgr/servicemgr_test.go b/src/controller/servicemgr/servicemgr_test.go
2 index 00d5ac2..caad3ac 100644
3 --- a/src/controller/servicemgr/servicemgr_test.go
4 +++ b/src/controller/servicemgr/servicemgr_test.go
13 @@ -26,6 +27,13 @@ import (
14 "common/networkhelper"
15 executorMock "controller/servicemgr/executor/mocks"
16 clientApiMock "restinterface/client/mocks"
17 + serviceDBMock "db/bolt/service/mocks"
18 + networkDBMock "db/bolt/network/mocks"
19 + configureDBMock "db/bolt/configuration/mocks"
20 + configureDB "db/bolt/configuration"
21 + networkDB "db/bolt/network"
22 + serviceDB "db/bolt/service"
23 + utilMock "common/utils/mocks"
25 "github.com/golang/mock/gomock"
27 @@ -43,6 +51,10 @@ const (
29 paramStr = []interface{}{"ls"}
30 paramStrWithArgs = []interface{}{"ls", "-ail"}
31 + mockServiceDB *serviceDBMock.MockDBInterface
32 + mockNetworkDB *networkDBMock.MockDBInterface
33 + mockConfDB *configureDBMock.MockDBInterface
34 + mockUtil *utilMock.MockUtilsHelper
38 @@ -101,6 +113,84 @@ func TestExecuteAppOnRemote(t *testing.T) {
42 +func TestGetAvailableDevices(t *testing.T) {
43 + serviceIns := GetInstance()
45 + ctrl := gomock.NewController(t)
50 + t.Run("Error", func(t *testing.T){
51 + var defaultServiceInfo []serviceDB.ServiceInfo
52 + mockServiceDB.EXPECT().GetList().Return(defaultServiceInfo, errors.New(""))
54 + _, err := serviceIns.GetAuthenticatedDevices("service", "extype")
56 + t.Error("Error should not be nil")
61 + t.Run("LengthZero", func(t *testing.T){
62 + var defaultServiceInfo []serviceDB.ServiceInfo
63 + mockServiceDB.EXPECT().GetList().Return(defaultServiceInfo, nil)
65 + _, err := serviceIns.GetAuthenticatedDevices("service", "extype")
67 + t.Error("Error should not be nil")
72 + t.Run("ServiceInfoSuccess", func(t *testing.T){
73 + servInfo := serviceDB.ServiceInfo{
75 + Services: []string{"defaultService"},
77 + var defaultServiceInfo []serviceDB.ServiceInfo
78 + defaultServiceInfo = append(defaultServiceInfo, servInfo)
80 + confInfo := configureDB.Configuration{
82 + ExecType: "defaultExecutionType",
83 + Platform : "defaultPlatform",
86 + netInfo := networkDB.NetworkInfo{
88 + IPv4 : []string{"192.168.1.10"},
93 + mockServiceDB.EXPECT().GetList().Return(defaultServiceInfo, nil),
94 + mockConfDB.EXPECT().Get(gomock.Any()).Return(confInfo, nil),
95 + mockNetworkDB.EXPECT().Get(gomock.Any()).Return(netInfo, nil),
96 + mockUtil.EXPECT().PingDevice(gomock.Any()).Return(true),
99 + _, err := serviceIns.GetAuthenticatedDevices("defaultService", "defaultExecutionType")
101 + t.Error("Error should not be there, received:", err.Error())
109 +func createMockIns(ctrl *gomock.Controller){
110 + mockServiceDB = serviceDBMock.NewMockDBInterface(ctrl)
111 + mockNetworkDB = networkDBMock.NewMockDBInterface(ctrl)
112 + mockConfDB = configureDBMock.NewMockDBInterface(ctrl)
113 + mockUtil = utilMock.NewMockUtilsHelper(ctrl)
115 + confDBExecutor = mockConfDB
116 + netDBExecutor = mockNetworkDB
117 + servDBExecutor = mockServiceDB
120 /**************** SERVICEMGR REST INIT TEST ***********************/
121 //func TestRestInit(t *testing.T) {