Cover the remainder of dispatcherprfl.go in engine

This commit is contained in:
ionutboangiu
2021-04-27 10:53:02 +03:00
committed by Dan Christian Bogos
parent 79a96d80f8
commit e8eafdd766

View File

@@ -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)
}
}