mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
100% coverage for attributes.go in dispatchers
This commit is contained in:
committed by
Dan Christian Bogos
parent
32f5414886
commit
1fcae3b075
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user