diff --git a/dispatchers/attributes_it_test.go b/dispatchers/attributes_it_test.go index 7c1260bdd..081e6539a 100644 --- a/dispatchers/attributes_it_test.go +++ b/dispatchers/attributes_it_test.go @@ -775,3 +775,52 @@ func TestDspAttributeSv1GetAttributeForEventErrorAttributeS(t *testing.T) { t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err) } } + +func TestDspAttributeSv1ProcessEventError(t *testing.T) { + cgrCfg := config.NewDefaultCGRConfig() + dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) + processEvent := &engine.AttrArgsProcessEvent{ + AttributeIDs: nil, + Context: nil, + ProcessRuns: nil, + CGREvent: &utils.CGREvent{ + Tenant: "tenant", + ID: "", + Time: &time.Time{}, + Event: nil, + APIOpts: nil, + }, + } + + var reply *engine.AttrSProcessEventReply + err := dspSrv.AttributeSv1ProcessEvent(processEvent, reply) + expected := "DISPATCHER_ERROR:NOT_FOUND" + if err == nil || err.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err) + } +} + +func TestDspAttributeSv1ProcessEventErrorAttributeSConns(t *testing.T) { + cgrCfg := config.NewDefaultCGRConfig() + cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"} + dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) + processEvent := &engine.AttrArgsProcessEvent{ + AttributeIDs: nil, + Context: nil, + ProcessRuns: nil, + CGREvent: &utils.CGREvent{ + Tenant: "tenant", + ID: "", + Time: &time.Time{}, + Event: nil, + APIOpts: nil, + }, + } + + var reply *engine.AttrSProcessEventReply + err := dspSrv.AttributeSv1ProcessEvent(processEvent, reply) + expected := "MANDATORY_IE_MISSING: [ApiKey]" + if err == nil || err.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err) + } +} diff --git a/dispatchers/caches_it_test.go b/dispatchers/caches_it_test.go index 68abe5607..07f0cafd9 100644 --- a/dispatchers/caches_it_test.go +++ b/dispatchers/caches_it_test.go @@ -26,6 +26,8 @@ import ( "testing" "time" + "github.com/cgrates/cgrates/config" + "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" "github.com/cgrates/ltcache" @@ -383,3 +385,32 @@ func testDspChcClear(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(expStats), utils.ToJSON(rcvStats)) } } + +func TestDspCacheSv1PingError(t *testing.T) { + cgrCfg := config.NewDefaultCGRConfig() + dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) + CGREvent := &utils.CGREvent{ + Tenant: "tenant", + ID: "", + Time: &time.Time{}, + Event: nil, + APIOpts: nil, + } + var reply *string + result := dspSrv.CacheSv1Ping(CGREvent, reply) + expected := "DISPATCHER_ERROR:NOT_FOUND" + if result == nil || result.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result) + } +} + +func TestDspCacheSv1PingErrorArgs(t *testing.T) { + cgrCfg := config.NewDefaultCGRConfig() + dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) + var reply *string + result := dspSrv.CacheSv1Ping(nil, reply) + expected := "DISPATCHER_ERROR:NOT_FOUND" + if result == nil || result.Error() != expected { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result) + } +}