Added test for DispatcherHost.Call

This commit is contained in:
Tripon Alexandru-Ionut
2019-04-10 14:05:20 +03:00
committed by Dan Christian Bogos
parent 472c68c897
commit 5ab62a688d
2 changed files with 39 additions and 1 deletions

View File

@@ -95,6 +95,12 @@ func testDspAttrPingFailover(t *testing.T) {
}
allEngine.startEngine(t)
allEngine2.startEngine(t)
reply = ""
if err := dispEngine.RCP.Call(utils.AttributeSv1Ping, &ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
}
func testDspAttrGetAttrFailover(t *testing.T) {

View File

@@ -221,5 +221,37 @@ func TestDispatcherProfilesSort(t *testing.T) {
if dProf.Sort(); !reflect.DeepEqual(eProf, dProf) {
t.Errorf("expecting: %+v, received: %+v", utils.ToJSON(eProf), utils.ToJSON(dProf))
}
}
type testRPCHost struct {
serviceMethod string
args interface{}
reply interface{}
}
func (v *testRPCHost) Call(serviceMethod string, args interface{}, reply interface{}) error {
v.serviceMethod = serviceMethod
v.args = args
v.reply = reply
return nil
}
func TestDispatcherHostCall(t *testing.T) {
tRPC := &testRPCHost{}
dspHost := DispatcherHost{}
etRPC := &testRPCHost{
serviceMethod: utils.AttributeSv1Ping,
args: &utils.CGREvent{},
reply: utils.StringPointer(""),
}
var reply string
if err := dspHost.Call(utils.AttributeSv1Ping, &utils.CGREvent{}, &reply); err == nil || err.Error() != utils.ErrNotConnected.Error() {
t.Errorf("Expected: %s , received: %v", utils.ErrNotConnected.Error(), err)
}
dspHost.rpcConn = tRPC
if err := dspHost.Call(utils.AttributeSv1Ping, &utils.CGREvent{}, &reply); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(*etRPC, *tRPC) {
t.Errorf("Expected: %s , received: %s", utils.ToJSON(etRPC), utils.ToJSON(tRPC))
}
}