mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
100% coverage for core.go in Dispatchers
This commit is contained in:
committed by
Dan Christian Bogos
parent
989137b438
commit
ab3458b6e4
@@ -25,6 +25,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
@@ -105,3 +106,84 @@ func testDspCoreLoad(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestDspCoreSv1StatusNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *map[string]interface{}
|
||||
result := dspSrv.CoreSv1Status(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1StatusErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantWithAPIOpts{}
|
||||
var reply *map[string]interface{}
|
||||
result := dspSrv.CoreSv1Status(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CoreSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1PingErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.CGREvent{}
|
||||
var reply *string
|
||||
result := dspSrv.CoreSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1SleepNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.DurationArgs{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CoreSv1Sleep(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1SleepErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.DurationArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.CoreSv1Sleep(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user