From e5db7a4e479df19cafbebff8c3b2eff5faa31b06 Mon Sep 17 00:00:00 2001 From: andronache Date: Tue, 20 Apr 2021 13:44:33 +0300 Subject: [PATCH] 95% Coverage in Dispatchers --- dispatchers/libdispatcher_test.go | 23 +++++++++++++++++------ engine/dispatcherprfl.go | 1 - 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/dispatchers/libdispatcher_test.go b/dispatchers/libdispatcher_test.go index 3107cd1c1..3017d723f 100644 --- a/dispatchers/libdispatcher_test.go +++ b/dispatchers/libdispatcher_test.go @@ -845,7 +845,12 @@ func TestLibDispatcherSingleResultStrategyDispatcherCastError(t *testing.T) { engine.Cache = cacheInit } -/* +type mockTypeCon struct{} + +func (*mockTypeCon) Call(serviceMethod string, args, reply interface{}) error { + return utils.ErrNotFound +} + func TestLibDispatcherSingleResultStrategyDispatcherCastError2(t *testing.T) { cacheInit := engine.Cache cfg := config.NewDefaultCGRConfig() @@ -856,20 +861,26 @@ func TestLibDispatcherSingleResultStrategyDispatcherCastError2(t *testing.T) { Tenant: "testTenant", RemoteHost: &config.RemoteHost{ ID: "testID", - Address: "", - Transport: "", + Address: rpcclient.InternalRPC, + Transport: utils.MetaInternal, Synchronous: false, TLS: false, }, } + + tmp := engine.IntRPC + engine.IntRPC = map[string]*rpcclient.RPCClient{} + chanRPC := make(chan rpcclient.ClientConnector, 1) + chanRPC <- new(mockTypeCon) + engine.IntRPC.AddInternalRPCClient(utils.AttributeSv1Ping, chanRPC) engine.Cache.SetWithoutReplicate(utils.CacheDispatcherRoutes, "testID:*attributes", value, nil, true, utils.NonTransactional) wgDsp := &singleResultstrategyDispatcher{} - err := wgDsp.dispatch(nil, "testID", utils.MetaAttributes, "testTenant", []string{"testID"}, utils.AttributeSv1Ping, &utils.CGREvent{}, "") - expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION" + err := wgDsp.dispatch(nil, "testID", utils.MetaAttributes, "testTenant", []string{"testID"}, utils.AttributeSv1Ping, &utils.CGREvent{}, &wgDsp) + expected := "UNSUPPORTED_SERVICE_METHOD" if err == nil || err.Error() != expected { t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err) } engine.Cache = cacheInit + engine.IntRPC = tmp } -*/ diff --git a/engine/dispatcherprfl.go b/engine/dispatcherprfl.go index 7bdb5074c..11aee7569 100644 --- a/engine/dispatcherprfl.go +++ b/engine/dispatcherprfl.go @@ -161,7 +161,6 @@ func (dH *DispatcherHost) Call(serviceMethod string, args interface{}, reply int utils.EmptyString, utils.EmptyString, nil); err != nil { return } - } return dH.rpcConn.Call(serviceMethod, args, reply) }