diff --git a/engine/handler_derivedcharging_test.go b/engine/handler_derivedcharging_test.go index f58c78c5b..e212e05dd 100644 --- a/engine/handler_derivedcharging_test.go +++ b/engine/handler_derivedcharging_test.go @@ -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) } diff --git a/engine/responder_test.go b/engine/responder_test.go index f0c7b60b7..64f0e1183 100644 --- a/engine/responder_test.go +++ b/engine/responder_test.go @@ -19,6 +19,7 @@ along with this program. If not, see 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) } } diff --git a/engine/storage_map.go b/engine/storage_map.go index b27391ab9..9782bb60d 100644 --- a/engine/storage_map.go +++ b/engine/storage_map.go @@ -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 { diff --git a/engine/storage_redis.go b/engine/storage_redis.go index 2db45ba1d..f702194b8 100644 --- a/engine/storage_redis.go +++ b/engine/storage_redis.go @@ -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