From 578453c76662b3fab81f4e420132c5e7b12d3fc7 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Tue, 7 Oct 2014 10:16:05 +0300 Subject: [PATCH] nu more empty balance map checking --- engine/storage_redis.go | 9 +++++++-- general_tests/acntacts_test.go | 7 ++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/engine/storage_redis.go b/engine/storage_redis.go index e6c185b41..74003d733 100644 --- a/engine/storage_redis.go +++ b/engine/storage_redis.go @@ -625,12 +625,17 @@ func (rs *RedisStorage) GetAccount(key string) (ub *Account, err error) { func (rs *RedisStorage) SetAccount(ub *Account) (err error) { // never override existing account with an empty one - if len(ub.BalanceMap) == 0 { + // UPDATE: if all balances expired and were clean it makes + // sense to write empty balance map + /*if len(ub.BalanceMap) == 0 { if ac, err := rs.GetAccount(ub.Id); err == nil { ac.ActionTriggers = ub.ActionTriggers + ac.UnitCounters = ub.UnitCounters + ac.AllowNegative = ub.AllowNegative + ac.Disabled = ub.Disabled ub = ac } - } + }*/ result, err := rs.ms.Marshal(ub) err = rs.db.Set(ACCOUNT_PREFIX+ub.Id, result) return diff --git a/general_tests/acntacts_test.go b/general_tests/acntacts_test.go index 8b6879bde..2d55c467f 100644 --- a/general_tests/acntacts_test.go +++ b/general_tests/acntacts_test.go @@ -19,9 +19,10 @@ along with this program. If not, see package general_tests import ( - "github.com/cgrates/cgrates/engine" "reflect" "testing" + + "github.com/cgrates/cgrates/engine" ) var ratingDbAcntActs engine.RatingStorage @@ -69,9 +70,6 @@ ENABLE_ACNT,*enable_account,,,,,,,,,,,10` } } -/* -//ToDo -// This test fails due to Disabled which is ignored on SetAccount with partial content. SetAccount should only be called with account when no previous one set in dataDb. func TestAcntActsDisableAcnt(t *testing.T) { acnt1Tag := "*out:cgrates.org:1" at := &engine.ActionTiming{ @@ -88,7 +86,6 @@ func TestAcntActsDisableAcnt(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", expectAcnt, acnt) } } -*/ func TestAcntActsEnableAcnt(t *testing.T) { acnt1Tag := "*out:cgrates.org:1"