mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add unit tests on engine
This commit is contained in:
committed by
Dan Christian Bogos
parent
064932367e
commit
c7ab22d43e
@@ -1606,3 +1606,35 @@ func TestRatingFieldAsInterface(t *testing.T) {
|
||||
t.Error("Expected error for invalid field within rating")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBalanceChargesClone(t *testing.T) {
|
||||
t.Run("Normal", func(t *testing.T) {
|
||||
original := &BalanceCharge{
|
||||
AccountID: "account1",
|
||||
BalanceUUID: "uuid1",
|
||||
RatingID: "rating1",
|
||||
Units: 100.5,
|
||||
BalanceFactor: 1.25,
|
||||
ExtraChargeID: "extraCharge01",
|
||||
}
|
||||
cloned := original.Clone()
|
||||
if cloned == nil {
|
||||
t.Errorf("Expected cloned BalanceCharge to be non-nil, but got nil")
|
||||
}
|
||||
if cloned.AccountID != original.AccountID || cloned.BalanceUUID != original.BalanceUUID ||
|
||||
cloned.RatingID != original.RatingID || cloned.Units != original.Units ||
|
||||
cloned.BalanceFactor != original.BalanceFactor || cloned.ExtraChargeID != original.ExtraChargeID {
|
||||
t.Errorf("Cloned BalanceCharge does not match original. Expected %+v, but got %+v", original, cloned)
|
||||
}
|
||||
if cloned == original {
|
||||
t.Errorf("Expected original and cloned BalanceCharge to be different instances, but they are the same")
|
||||
}
|
||||
})
|
||||
t.Run("NilReceiver", func(t *testing.T) {
|
||||
var original *BalanceCharge
|
||||
cloned := original.Clone()
|
||||
if cloned != nil {
|
||||
t.Errorf("Expected cloned BalanceCharge to be nil, but got %+v", cloned)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1176,3 +1176,31 @@ func TestStatQueueUnmarshalJSON(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestLibRoutesRouteIDs(t *testing.T) {
|
||||
sortedRoutesList := SortedRoutesList{
|
||||
{
|
||||
Routes: []*SortedRoute{
|
||||
{RouteID: "1"},
|
||||
{RouteID: "2"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Routes: []*SortedRoute{
|
||||
{RouteID: "3"},
|
||||
{RouteID: "4"},
|
||||
},
|
||||
},
|
||||
}
|
||||
expectedIDs := []string{"1", "2", "3", "4"}
|
||||
actualIDs := sortedRoutesList.RouteIDs()
|
||||
if len(actualIDs) != len(expectedIDs) {
|
||||
t.Errorf("expected length %d, got %d", len(expectedIDs), len(actualIDs))
|
||||
return
|
||||
}
|
||||
for i := range expectedIDs {
|
||||
if actualIDs[i] != expectedIDs[i] {
|
||||
t.Errorf("at index %d, expected %s, got %s", i, expectedIDs[i], actualIDs[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user