action plan interation tests

This commit is contained in:
Radu Ioan Fericean
2015-12-18 16:21:27 +02:00
parent 37c60afeed
commit ef5c6c78a7
2 changed files with 8 additions and 7 deletions

View File

@@ -21,6 +21,7 @@ package engine
import (
"flag"
"path"
"strings"
"testing"
"github.com/cgrates/cgrates/config"
@@ -395,7 +396,7 @@ func TestMatchLoadCsvWithStorRating(t *testing.T) {
for _, key := range keysCsv {
var refVal []byte
for idx, rs := range []*RedisStorage{rsCsv, rsStor, rsApier} {
if key == utils.TASKS_KEY {
if key == utils.TASKS_KEY || strings.HasPrefix(key, utils.ACTION_PLAN_PREFIX) { // action plans are not consistent
continue
}
qVal, err := rs.db.Cmd("GET", key).Bytes()

View File

@@ -904,7 +904,7 @@ func (rs *RedisStorage) GetActionPlan(key string, skipCache bool) (ats *ActionPl
}
var values []byte
if values, err = rs.db.Cmd("GET", key).Bytes(); err == nil {
/*b := bytes.NewBuffer(values)
b := bytes.NewBuffer(values)
r, err := zlib.NewReader(b)
if err != nil {
return nil, err
@@ -913,8 +913,8 @@ func (rs *RedisStorage) GetActionPlan(key string, skipCache bool) (ats *ActionPl
if err != nil {
return nil, err
}
r.Close()*/
err = rs.ms.Unmarshal(values, &ats)
r.Close()
err = rs.ms.Unmarshal(out, &ats)
cache2go.Cache(key, ats)
}
return
@@ -932,10 +932,10 @@ func (rs *RedisStorage) SetActionPlan(key string, ats *ActionPlan) (err error) {
return err
}
var b bytes.Buffer
/*w := zlib.NewWriter(&b)
w := zlib.NewWriter(&b)
w.Write(result)
w.Close()*/
return rs.db.Cmd("SET", utils.ACTION_PLAN_PREFIX+key, result).Err
w.Close()
return rs.db.Cmd("SET", utils.ACTION_PLAN_PREFIX+key, b.Bytes()).Err
}
func (rs *RedisStorage) GetAllActionPlans() (ats map[string]*ActionPlan, err error) {