mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Addded tests for dispatchers/attributes.go
This commit is contained in:
committed by
Dan Christian Bogos
parent
1140de6a6c
commit
b54d3a92a1
@@ -23,6 +23,7 @@ package dispatchers
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
@@ -702,3 +703,75 @@ func TestDspAttributeSv1PingErrorAttributeSConns(t *testing.T) {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1GetAttributeForEventError(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: "",
|
||||
ID: "",
|
||||
Time: &time.Time{},
|
||||
Event: nil,
|
||||
APIOpts: nil,
|
||||
},
|
||||
}
|
||||
var reply *engine.AttributeProfile
|
||||
err := dspSrv.AttributeSv1GetAttributeForEvent(processEvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1GetAttributeForEventErrorTenant(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.AttributeProfile
|
||||
err := dspSrv.AttributeSv1GetAttributeForEvent(processEvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspAttributeSv1GetAttributeForEventErrorAttributeS(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.AttributeProfile
|
||||
err := dspSrv.AttributeSv1GetAttributeForEvent(processEvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NOT_FOUND"
|
||||
if err == nil || err.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user