mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated utils tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
2ce94a020d
commit
3b9cc4895a
@@ -192,18 +192,18 @@ func (eeC *EventExporterCfg) loadFromJsonCfg(jsnEec *EventExporterJsonCfg, separ
|
||||
eeC.headerFields = make([]*FCTemplate, 0)
|
||||
eeC.contentFields = make([]*FCTemplate, 0)
|
||||
eeC.trailerFields = make([]*FCTemplate, 0)
|
||||
if eeC.Fields, err = FCTemplatesFromFCTemplatesJsonCfg(*jsnEec.Fields, separator); err != nil {
|
||||
return err
|
||||
} else {
|
||||
for _, field := range eeC.Fields {
|
||||
switch field.GetPathSlice()[0] {
|
||||
case utils.MetaHdr:
|
||||
eeC.headerFields = append(eeC.headerFields, field)
|
||||
case utils.MetaExp:
|
||||
eeC.contentFields = append(eeC.contentFields, field)
|
||||
case utils.MetaTrl:
|
||||
eeC.trailerFields = append(eeC.trailerFields, field)
|
||||
}
|
||||
eeC.Fields, err = FCTemplatesFromFCTemplatesJsonCfg(*jsnEec.Fields, separator)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for _, field := range eeC.Fields {
|
||||
switch field.GetPathSlice()[0] {
|
||||
case utils.MetaHdr:
|
||||
eeC.headerFields = append(eeC.headerFields, field)
|
||||
case utils.MetaExp:
|
||||
eeC.contentFields = append(eeC.contentFields, field)
|
||||
case utils.MetaTrl:
|
||||
eeC.trailerFields = append(eeC.trailerFields, field)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,8 +92,9 @@ func TestAccountStorageStoreRestore(t *testing.T) {
|
||||
b2 := &Balance{Value: 100, Weight: 20,
|
||||
DestinationIDs: utils.StringMap{"RET": true}}
|
||||
rifsBalance := &Account{ID: "other",
|
||||
BalanceMap: map[string]Balances{utils.VOICE: Balances{b1, b2},
|
||||
utils.MONETARY: Balances{&Balance{Value: 21}}}}
|
||||
BalanceMap: map[string]Balances{
|
||||
utils.VOICE: {b1, b2},
|
||||
utils.MONETARY: {&Balance{Value: 21}}}}
|
||||
dm.SetAccount(rifsBalance)
|
||||
ub1, err := dm.GetAccount("other")
|
||||
if err != nil ||
|
||||
@@ -110,8 +111,8 @@ func TestGetSecondsForPrefix(t *testing.T) {
|
||||
DestinationIDs: utils.StringMap{"RET": true}}
|
||||
ub1 := &Account{ID: "CUSTOMER_1:rif",
|
||||
BalanceMap: map[string]Balances{
|
||||
utils.VOICE: Balances{b1, b2},
|
||||
utils.MONETARY: Balances{&Balance{Value: 200}}}}
|
||||
utils.VOICE: {b1, b2},
|
||||
utils.MONETARY: {&Balance{Value: 200}}}}
|
||||
cd := &CallDescriptor{
|
||||
Category: "0",
|
||||
Tenant: "vdf",
|
||||
@@ -139,8 +140,8 @@ func TestGetSpecialPricedSeconds(t *testing.T) {
|
||||
ub1 := &Account{
|
||||
ID: "OUT:CUSTOMER_1:rif",
|
||||
BalanceMap: map[string]Balances{
|
||||
utils.VOICE: Balances{b1, b2},
|
||||
utils.MONETARY: Balances{&Balance{Value: 21}},
|
||||
utils.VOICE: {b1, b2},
|
||||
utils.MONETARY: {&Balance{Value: 21}},
|
||||
},
|
||||
}
|
||||
cd := &CallDescriptor{
|
||||
@@ -219,7 +220,7 @@ func TestDebitCreditZeroSecond(t *testing.T) {
|
||||
var err error
|
||||
cc, err = rifsBalance.debitCreditBalance(cd, false, false, true)
|
||||
if err != nil {
|
||||
t.Error("Error debiting balance: ", err)
|
||||
t.Fatal("Error debiting balance: ", err)
|
||||
}
|
||||
if cc.Timespans[0].Increments[0].BalanceInfo.Unit.UUID != "testb" {
|
||||
t.Logf("%+v", cc.Timespans[0])
|
||||
|
||||
@@ -167,12 +167,12 @@ func (chS *CacheS) RollbackTransaction(transID string) {
|
||||
chS.tCache.RollbackTransaction(transID)
|
||||
}
|
||||
|
||||
// RollbackTransaction is an exported method from TransCache
|
||||
// CommitTransaction is an exported method from TransCache
|
||||
func (chS *CacheS) CommitTransaction(transID string) {
|
||||
chS.tCache.CommitTransaction(transID)
|
||||
}
|
||||
|
||||
// RollbackTransaction is an exported method from TransCache
|
||||
// GetCloned is an exported method from TransCache
|
||||
func (chS *CacheS) GetCloned(chID, itmID string) (cln interface{}, err error) {
|
||||
return chS.tCache.GetCloned(chID, itmID)
|
||||
}
|
||||
|
||||
@@ -1009,7 +1009,6 @@ func (ms *MongoStorage) SetReverseDestinationDrv(dest *Destination,
|
||||
)
|
||||
return err
|
||||
}); err != nil {
|
||||
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,3 +155,11 @@ func TestGetPathWithoutIndex(t *testing.T) {
|
||||
t.Errorf("Expected: %s, received: %s", expected, rply)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPathItemsSlice(t *testing.T) {
|
||||
expected := []string{"*req", "Field1[0]", "Account"}
|
||||
path := NewPathItems(expected)
|
||||
if rply := path.Slice(); !reflect.DeepEqual(expected, rply) {
|
||||
t.Errorf("Expected: %q, received: %q", expected, rply)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user