dataDb should not be read when cache is searched, tests updates

This commit is contained in:
DanB
2014-09-04 18:36:46 +02:00
parent 7b2ba2aeb9
commit 886ca68eb8
4 changed files with 43 additions and 4 deletions

View File

@@ -31,7 +31,11 @@ var acntDb AccountingStorage
func init() {
cfgDcT, _ = config.NewDefaultCGRConfig()
acntDb = accountingStorage
if DEBUG {
acntDb, _ = NewMapStorage()
} else {
acntDb, _ = NewRedisStorage("127.0.0.1:6379", 13, "", utils.MSGPACK)
}
acntDb.CacheAccounting(nil, nil, nil, nil)
}

View File

@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package engine
import (
"fmt"
"reflect"
"testing"
@@ -34,12 +35,14 @@ func TestResponderGetDerivedChargers(t *testing.T) {
cfg.DerivedChargers = cfgedDC
config.SetCgrConfig(cfg)
r := Responder{}
attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "dan", Subject: "dan"}
attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "responder_test", Subject: "responder_test"}
var dcs utils.DerivedChargers
if err := r.GetDerivedChargers(attrs, &dcs); err != nil {
t.Error("Unexpected error", err.Error())
} else if !reflect.DeepEqual(dcs, cfgedDC) {
//t.Errorf("Expecting: %v, received: %v ", cfgedDC, dcs)
//FIXME: fix the above test
for _, dc := range dcs {
fmt.Printf("DerivedCharger: %+v\n", dc)
}
t.Errorf("Expecting: %v, received: %v ", cfgedDC, dcs)
}
}

View File

@@ -177,6 +177,8 @@ func (ms *MapStorage) GetRatingPlan(key string, skipCache bool) (rp *RatingPlan,
if !skipCache {
if x, err := cache2go.GetCached(key); err == nil {
return x.(*RatingPlan), nil
} else {
return nil, err
}
}
if values, ok := ms.dict[key]; ok {
@@ -219,6 +221,8 @@ func (ms *MapStorage) GetRatingProfile(key string, skipCache bool) (rpf *RatingP
if !skipCache {
if x, err := cache2go.GetCached(key); err == nil {
return x.(*RatingProfile), nil
} else {
return nil, err
}
}
if values, ok := ms.dict[key]; ok {
@@ -248,6 +252,8 @@ func (ms *MapStorage) GetLCR(key string, skipCache bool) (lcr *LCR, err error) {
if !skipCache {
if x, err := cache2go.GetCached(key); err == nil {
return x.(*LCR), nil
} else {
return nil, err
}
}
if values, ok := ms.dict[key]; ok {
@@ -271,6 +277,8 @@ func (ms *MapStorage) GetRpAlias(key string, skipCache bool) (alias string, err
if !skipCache {
if x, err := cache2go.GetCached(key); err == nil {
return x.(string), nil
} else {
return "", err
}
}
if values, ok := ms.dict[key]; ok {
@@ -336,6 +344,8 @@ func (ms *MapStorage) GetAccAlias(key string, skipCache bool) (alias string, err
if !skipCache {
if x, err := cache2go.GetCached(key); err == nil {
return x.(string), nil
} else {
return "", err
}
}
if values, ok := ms.dict[key]; ok {
@@ -420,6 +430,8 @@ func (ms *MapStorage) GetActions(key string, skipCache bool) (as Actions, err er
if !skipCache {
if x, err := cache2go.GetCached(key); err == nil {
return x.(Actions), nil
} else {
return nil, err
}
}
if values, ok := ms.dict[key]; ok {
@@ -443,6 +455,8 @@ func (ms *MapStorage) GetSharedGroup(key string, skipCache bool) (sg *SharedGrou
if !skipCache {
if x, err := cache2go.GetCached(key); err == nil {
return x.(*SharedGroup), nil
} else {
return nil, err
}
}
if values, ok := ms.dict[key]; ok {
@@ -523,6 +537,8 @@ func (ms *MapStorage) GetDerivedChargers(key string, skipCache bool) (dcs utils.
if !skipCache {
if x, err := cache2go.GetCached(key); err == nil {
return x.(utils.DerivedChargers), nil
} else {
return nil, err
}
}
if values, ok := ms.dict[key]; ok {

View File

@@ -278,6 +278,8 @@ func (rs *RedisStorage) GetRatingPlan(key string, skipCache bool) (rp *RatingPla
if !skipCache {
if x, err := cache2go.GetCached(key); err == nil {
return x.(*RatingPlan), nil
} else {
return nil, err
}
}
var values []byte
@@ -320,6 +322,8 @@ func (rs *RedisStorage) GetRatingProfile(key string, skipCache bool) (rpf *Ratin
if !skipCache {
if x, err := cache2go.GetCached(key); err == nil {
return x.(*RatingProfile), nil
} else {
return nil, err
}
}
var values []byte
@@ -347,6 +351,8 @@ func (rs *RedisStorage) GetRpAlias(key string, skipCache bool) (alias string, er
if !skipCache {
if x, err := cache2go.GetCached(key); err == nil {
return x.(string), nil
} else {
return "", err
}
}
var values []byte
@@ -418,6 +424,8 @@ func (rs *RedisStorage) GetLCR(key string, skipCache bool) (lcr *LCR, err error)
if !skipCache {
if x, err := cache2go.GetCached(key); err == nil {
return x.(*LCR), nil
} else {
return nil, err
}
}
var values []byte
@@ -440,6 +448,8 @@ func (rs *RedisStorage) GetAccAlias(key string, skipCache bool) (alias string, e
if !skipCache {
if x, err := cache2go.GetCached(key); err == nil {
return x.(string), nil
} else {
return "", err
}
}
var values []byte
@@ -556,6 +566,8 @@ func (rs *RedisStorage) GetActions(key string, skipCache bool) (as Actions, err
if !skipCache {
if x, err := cache2go.GetCached(key); err == nil {
return x.(Actions), nil
} else {
return nil, err
}
}
var values []byte
@@ -578,6 +590,8 @@ func (rs *RedisStorage) GetSharedGroup(key string, skipCache bool) (sg *SharedGr
if !skipCache {
if x, err := cache2go.GetCached(key); err == nil {
return x.(*SharedGroup), nil
} else {
return nil, err
}
}
var values []byte
@@ -661,6 +675,8 @@ func (rs *RedisStorage) GetDerivedChargers(key string, skipCache bool) (dcs util
if !skipCache {
if x, err := cache2go.GetCached(key); err == nil {
return x.(utils.DerivedChargers), nil
} else {
return nil, err
}
}
var values []byte