mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated logger message
This commit is contained in:
committed by
Dan Christian Bogos
parent
808df2963c
commit
794e60e5df
@@ -920,7 +920,7 @@ func (cd *CallDescriptor) refundIncrements() (acnt *Account, err error) {
|
||||
// check money too
|
||||
if increment.BalanceInfo.Monetary != nil && increment.BalanceInfo.Monetary.UUID != "" {
|
||||
if balance = account.BalanceMap[utils.MONETARY].GetBalance(increment.BalanceInfo.Monetary.UUID); balance == nil {
|
||||
utils.Logger.Warning(fmt.Sprintf("Could not get the balnce: <%s> to be refunded for account: <%s>", increment.BalanceInfo.Unit.UUID, increment.BalanceInfo.AccountID))
|
||||
utils.Logger.Warning(fmt.Sprintf("Could not get the balnce: <%s> to be refunded for account: <%s>", increment.BalanceInfo.Monetary.UUID, increment.BalanceInfo.AccountID))
|
||||
continue
|
||||
}
|
||||
balance.AddValue(increment.Cost)
|
||||
|
||||
@@ -2017,3 +2017,29 @@ func BenchmarkStorageMultipleGetSessionTime(b *testing.B) {
|
||||
cd.GetMaxSessionDuration()
|
||||
}
|
||||
}
|
||||
|
||||
func TestCDRefundIncrementspanic(t *testing.T) {
|
||||
ub := &Account{
|
||||
ID: "test:refpanic",
|
||||
BalanceMap: map[string]Balances{
|
||||
utils.MONETARY: {
|
||||
&Balance{Uuid: "moneya", Value: 100},
|
||||
},
|
||||
},
|
||||
}
|
||||
dm.SetAccount(ub)
|
||||
increments := Increments{
|
||||
&Increment{Cost: 2, BalanceInfo: &DebitInfo{
|
||||
Monetary: &MonetaryInfo{UUID: "moneya2"}, AccountID: ub.ID}},
|
||||
}
|
||||
cd := &CallDescriptor{ToR: utils.VOICE, Increments: increments}
|
||||
if _, err := cd.refundIncrements(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ub, _ = dm.GetAccount(ub.ID)
|
||||
if ub.BalanceMap[utils.MONETARY][0].GetValue() != 100 || // no refund because of missing balance with ID
|
||||
len(ub.BalanceMap) != 1 ||
|
||||
len(ub.BalanceMap[utils.MONETARY]) != 1 {
|
||||
t.Error("Error refunding money: ", utils.ToIJSON(ub.BalanceMap))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user