Updated logger message

This commit is contained in:
Trial97
2021-12-13 16:03:08 +02:00
committed by Dan Christian Bogos
parent 808df2963c
commit 794e60e5df
2 changed files with 27 additions and 1 deletions

View File

@@ -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)

View File

@@ -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))
}
}