diff --git a/engine/action_trigger_test.go b/engine/action_trigger_test.go index 86fc71faa..9e6f0c017 100644 --- a/engine/action_trigger_test.go +++ b/engine/action_trigger_test.go @@ -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) + } +} diff --git a/engine/argees_test.go b/engine/argees_test.go index 0da1e4e3d..eba082a62 100644 --- a/engine/argees_test.go +++ b/engine/argees_test.go @@ -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)") + } +} diff --git a/engine/models_test.go b/engine/models_test.go index 0700d2b2d..3778018d7 100644 --- a/engine/models_test.go +++ b/engine/models_test.go @@ -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) + } +} diff --git a/engine/ratingprofile_test.go b/engine/ratingprofile_test.go index 67e98a3db..e86abb0bf 100644 --- a/engine/ratingprofile_test.go +++ b/engine/ratingprofile_test.go @@ -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") + } +}