Cover tests in Dispatchers for resources.go and replicator.go

This commit is contained in:
andronache
2021-04-08 16:32:57 +03:00
committed by Dan Christian Bogos
parent d38a8b536e
commit 88fe1db5aa

View File

@@ -2374,3 +2374,123 @@ func TestDspReplicatorSv1GetDispatcherProfileErrorNil(t *testing.T) {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
}
}
func TestDspReplicatorSv1GetDispatcherHostNil(t *testing.T) {
cgrCfg := config.NewDefaultCGRConfig()
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
CGREvent := &utils.TenantIDWithAPIOpts{
TenantID: &utils.TenantID{
Tenant: "tenant",
},
}
var reply *engine.DispatcherHost
result := dspSrv.ReplicatorSv1GetDispatcherHost(CGREvent, reply)
expected := "MANDATORY_IE_MISSING: [ApiKey]"
if result == nil || result.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
}
}
func TestDspReplicatorSv1GetDispatcherHostErrorNil(t *testing.T) {
cgrCfg := config.NewDefaultCGRConfig()
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
CGREvent := &utils.TenantIDWithAPIOpts{
TenantID: &utils.TenantID{
Tenant: "tenant",
},
}
var reply *engine.DispatcherHost
result := dspSrv.ReplicatorSv1GetDispatcherHost(CGREvent, reply)
expected := "DISPATCHER_ERROR:NOT_FOUND"
if result == nil || result.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
}
}
func TestDspReplicatorSv1GetItemLoadIDsNilEvent(t *testing.T) {
cgrCfg := config.NewDefaultCGRConfig()
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
var reply *map[string]int64
result := dspSrv.ReplicatorSv1GetItemLoadIDs(nil, reply)
expected := "MANDATORY_IE_MISSING: [ApiKey]"
if result == nil || result.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
}
}
func TestDspReplicatorSv1GetItemLoadIDsNil(t *testing.T) {
cgrCfg := config.NewDefaultCGRConfig()
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
CGREvent := &utils.StringWithAPIOpts{
Tenant: "tenant",
}
var reply *map[string]int64
result := dspSrv.ReplicatorSv1GetItemLoadIDs(CGREvent, reply)
expected := "MANDATORY_IE_MISSING: [ApiKey]"
if result == nil || result.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
}
}
func TestDspReplicatorSv1GetItemLoadIDsErrorNil(t *testing.T) {
cgrCfg := config.NewDefaultCGRConfig()
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
CGREvent := &utils.StringWithAPIOpts{
Tenant: "tenant",
}
var reply *map[string]int64
result := dspSrv.ReplicatorSv1GetItemLoadIDs(CGREvent, reply)
expected := "DISPATCHER_ERROR:NOT_FOUND"
if result == nil || result.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
}
}
func TestDspReplicatorSv1SetThresholdProfileNil(t *testing.T) {
cgrCfg := config.NewDefaultCGRConfig()
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
CGREvent := &engine.ThresholdProfileWithAPIOpts{
ThresholdProfile: &engine.ThresholdProfile{
Tenant: "tenant",
},
}
var reply *string
result := dspSrv.ReplicatorSv1SetThresholdProfile(CGREvent, reply)
expected := "MANDATORY_IE_MISSING: [ApiKey]"
if result == nil || result.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
}
}
func TestDspReplicatorSv1SetThresholdProfileErrorNil(t *testing.T) {
cgrCfg := config.NewDefaultCGRConfig()
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
CGREvent := &engine.ThresholdProfileWithAPIOpts{
ThresholdProfile: &engine.ThresholdProfile{
Tenant: "tenant",
},
}
var reply *string
result := dspSrv.ReplicatorSv1SetThresholdProfile(CGREvent, reply)
expected := "DISPATCHER_ERROR:NOT_FOUND"
if result == nil || result.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
}
}
func TestDspReplicatorSv1SetThresholdProfileNilEvent(t *testing.T) {
cgrCfg := config.NewDefaultCGRConfig()
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
var CGREvent *engine.ThresholdProfileWithAPIOpts
var reply *string
result := dspSrv.ReplicatorSv1SetThresholdProfile(CGREvent, reply)
expected := "MANDATORY_IE_MISSING: [ApiKey]"
if result == nil || result.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
}
}