From e8eafdd76661c53fe350d3d25fc2b6c646f42bf8 Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Tue, 27 Apr 2021 10:53:02 +0300 Subject: [PATCH] Cover the remainder of dispatcherprfl.go in engine --- engine/dispatcherprfl_test.go | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/engine/dispatcherprfl_test.go b/engine/dispatcherprfl_test.go index 38772212e..7c23d0a3b 100644 --- a/engine/dispatcherprfl_test.go +++ b/engine/dispatcherprfl_test.go @@ -21,6 +21,7 @@ import ( "reflect" "testing" + "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/utils" ) @@ -293,3 +294,47 @@ func TestDispatcherHostIDsProfilesClone(t *testing.T) { t.Errorf("expecting: %+v, received: %+v", utils.ToJSON(eConns), utils.ToJSON(dConns)) } } + +func TestDispatcherHostProfileCloneWithParams(t *testing.T) { + dC := &DispatcherHostProfile{ + ID: "testID", + Weight: 10, + Blocker: false, + Params: map[string]interface{}{ + "param1": "value of param1", + "param2": "value of param2", + }, + } + + exp := &DispatcherHostProfile{ + ID: "testID", + Weight: 10, + Blocker: false, + Params: map[string]interface{}{ + "param1": "value of param1", + "param2": "value of param2", + }, + } + rcv := dC.Clone() + + if !reflect.DeepEqual(rcv, exp) { + t.Errorf("\nexpected: <%+v>, \nreceived: <%+v", exp, rcv) + } +} + +func TestDispatcherHostCallNilRPCConn(t *testing.T) { + dH := &DispatcherHost{ + Tenant: "cgrates.org", + RemoteHost: config.NewDfltRemoteHost(), + } + + var args int + var reply *int + + experr := "dial tcp 127.0.0.1:2012: connect: connection refused" + err := dH.Call("method", args, reply) + + if err == nil || err.Error() != experr { + t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err) + } +}