show error on not enough credit when debiting

This commit is contained in:
Radu Ioan Fericean
2013-12-04 21:25:36 +02:00
parent 131997507d
commit 10dea0c55d
2 changed files with 6 additions and 6 deletions

View File

@@ -472,8 +472,8 @@ func (ub *UserBalance) debitCreditBalance(cc *CallCost, count bool) error {
ts.SplitByIncrement(incrementIndex)
cc.Timespans = cc.Timespans[:tsIndex+1]
}
//return errors.New("Not enough credit")
return nil
return errors.New("Not enough credit")
//return nil
}
}
}

View File

@@ -327,8 +327,8 @@ func TestDebitCreditNoCredit(t *testing.T) {
MINUTES + OUTBOUND: BalanceChain{b1},
}}
err := rifsBalance.debitCreditBalance(cc, false)
if err != nil {
t.Error("Error debiting balance: ", err)
if err == nil {
t.Error("Showing no enough credit error ")
}
if cc.Timespans[0].Increments[0].BalanceUuids[0] != "testb" ||
cc.Timespans[0].Increments[0].Duration != time.Minute {
@@ -556,8 +556,8 @@ func TestDebitCreditMoneyOnly(t *testing.T) {
CREDIT + OUTBOUND: BalanceChain{&Balance{Uuid: "money", Value: 50}},
}}
err := rifsBalance.debitCreditBalance(cc, false)
if err != nil {
t.Error("Error debiting balance: ", err)
if err == nil {
t.Error("Missing noy enough credit error ")
}
if cc.Timespans[0].Increments[0].BalanceUuids[0] != "money" ||