mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add new unit tests in engine
This commit is contained in:
committed by
Dan Christian Bogos
parent
68f1663688
commit
39e3d04fe5
@@ -379,3 +379,58 @@ func TestATExecute22(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineActionTriggerEquals(t *testing.T) {
|
||||
at1 := &ActionTrigger{
|
||||
ID: "trigger1",
|
||||
UniqueID: "unique1",
|
||||
ThresholdType: "threshold1",
|
||||
ThresholdValue: 10.0,
|
||||
Recurrent: true,
|
||||
MinSleep: time.Minute,
|
||||
ExpirationDate: time.Now().AddDate(0, 0, 1),
|
||||
ActivationDate: time.Now(),
|
||||
Weight: 1.0,
|
||||
ActionsID: "action1",
|
||||
MinQueuedItems: 5,
|
||||
Executed: false,
|
||||
LastExecutionTime: time.Now(),
|
||||
}
|
||||
|
||||
at2 := &ActionTrigger{
|
||||
ID: "trigger1",
|
||||
UniqueID: "unique1",
|
||||
ThresholdType: "threshold1",
|
||||
ThresholdValue: 10.0,
|
||||
Recurrent: true,
|
||||
MinSleep: time.Minute,
|
||||
ExpirationDate: time.Now().AddDate(0, 0, 1),
|
||||
ActivationDate: time.Now(),
|
||||
Weight: 1.0,
|
||||
ActionsID: "action1",
|
||||
MinQueuedItems: 5,
|
||||
Executed: false,
|
||||
LastExecutionTime: time.Now(),
|
||||
}
|
||||
at3 := &ActionTrigger{
|
||||
ID: "trigger2",
|
||||
UniqueID: "unique2",
|
||||
ThresholdType: "threshold2",
|
||||
ThresholdValue: 20.0,
|
||||
Recurrent: false,
|
||||
MinSleep: time.Minute,
|
||||
ExpirationDate: time.Now().AddDate(0, 0, 1),
|
||||
ActivationDate: time.Now(),
|
||||
Weight: 2.0,
|
||||
ActionsID: "action2",
|
||||
MinQueuedItems: 10,
|
||||
Executed: false,
|
||||
LastExecutionTime: time.Now(),
|
||||
}
|
||||
if !at1.Equals(at2) {
|
||||
t.Errorf("Expected %v to equal %v, but it didn't.", at1, at2)
|
||||
}
|
||||
if at1.Equals(at3) {
|
||||
t.Errorf("Expected %v not to equal %v, but it did.", at1, at3)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,3 +128,16 @@ func TestArgEEsUnmarshalJSON(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestEngineCGREventWithEeIDsSetCloneable(t *testing.T) {
|
||||
attr := &CGREventWithEeIDs{
|
||||
CGREvent: &utils.CGREvent{}}
|
||||
attr.SetCloneable(true)
|
||||
if !attr.clnb {
|
||||
t.Error("Expected attribute.clnb to be true after calling SetCloneable(true)")
|
||||
}
|
||||
attr.SetCloneable(false)
|
||||
if attr.clnb {
|
||||
t.Error("Expected attribute.clnb to be false after calling SetCloneable(false)")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,3 +262,75 @@ func TestEngineThresholdMdlTableName(t *testing.T) {
|
||||
t.Errorf("\nExpected: <%+v>\nReceived: <%+v>", exp, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineTableNameTPfilters(t *testing.T) {
|
||||
want := "tp_filters"
|
||||
got := FilterMdl{}.TableName()
|
||||
if got != want {
|
||||
t.Errorf("Expected TableName(): %s, got: %s", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineTableNameCdrs(t *testing.T) {
|
||||
want := "cdrs"
|
||||
got := CDRsql{}.TableName()
|
||||
if got != want {
|
||||
t.Errorf("Expected TableName(): %s, got: %s", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineTableNameSessionCosts(t *testing.T) {
|
||||
want := "session_costs"
|
||||
got := SessionCostsSQL{}.TableName()
|
||||
if got != want {
|
||||
t.Errorf("Expected TableName(): %s, got: %s", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineTableNameTBLVersions(t *testing.T) {
|
||||
expected := "versions"
|
||||
got := TBLVersion{}.TableName()
|
||||
if got != expected {
|
||||
t.Errorf("Expected TableName(): %s, got: %s", expected, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineTableNameTbltpRoutes(t *testing.T) {
|
||||
want := "tp_routes"
|
||||
got := RouteMdl{}.TableName()
|
||||
if got != want {
|
||||
t.Errorf("Expected TableName(): %s, got: %s", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineTableNameTPAttributeMdl(t *testing.T) {
|
||||
want := "tp_attributes"
|
||||
got := AttributeMdl{}.TableName()
|
||||
if got != want {
|
||||
t.Errorf("Expected TableName(): %s, got: %s", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineTableNameChargerMdl(t *testing.T) {
|
||||
want := "tp_chargers"
|
||||
got := ChargerMdl{}.TableName()
|
||||
if got != want {
|
||||
t.Errorf("Expected TableName(): %s, got: %s", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineTableNameDispatcherProfileMdl(t *testing.T) {
|
||||
want := "tp_dispatcher_profiles"
|
||||
got := DispatcherProfileMdl{}.TableName()
|
||||
if got != want {
|
||||
t.Errorf("Expected TableName(): %s, got: %s", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineTableNameDispatcherHostMdl(t *testing.T) {
|
||||
want := "tp_dispatcher_hosts"
|
||||
got := DispatcherHostMdl{}.TableName()
|
||||
if got != want {
|
||||
t.Errorf("Expected TableName(): %s, got: %s", got, got)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -526,3 +526,27 @@ func TestEngineEqualRpaOrpa(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineSwapIndexRis(t *testing.T) {
|
||||
ris := RatingInfos{
|
||||
&RatingInfo{MatchedSubject: "Cgrates1"},
|
||||
&RatingInfo{MatchedSubject: "Cgrates2"},
|
||||
&RatingInfo{MatchedSubject: "Cgrates3"},
|
||||
}
|
||||
i, j := 0, 2
|
||||
ris.Swap(i, j)
|
||||
if ris[i].MatchedSubject != "Cgrates3" || ris[j].MatchedSubject != "Cgrates1" {
|
||||
t.Errorf("Swap did not swap elements correctly")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineLessRis(t *testing.T) {
|
||||
ris := RatingInfos{
|
||||
&RatingInfo{ActivationTime: time.Now()},
|
||||
&RatingInfo{ActivationTime: time.Now().Add(time.Hour)},
|
||||
&RatingInfo{ActivationTime: time.Now().Add(-time.Hour)},
|
||||
}
|
||||
if ris.Less(0, 2) {
|
||||
t.Errorf("Expected first element not to be less than the third one")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user