unmarshal test keys before comparison

This commit is contained in:
Radu Ioan Fericean
2015-11-05 12:49:20 +02:00
parent 189a893134
commit 0244ddc7e1

View File

@@ -21,6 +21,7 @@ package engine
import (
"flag"
"path"
"reflect"
"testing"
"github.com/cgrates/cgrates/config"
@@ -393,18 +394,20 @@ func TestMatchLoadCsvWithStorRating(t *testing.T) {
t.Fatal("Failed querying redis keys for csv data")
}
for _, key := range keysCsv {
var refVal []byte
var refMap map[string]interface{}
for idx, rs := range []*RedisStorage{rsCsv, rsStor, rsApier} {
qVal, err := rs.db.Get(key)
qMap := make(map[string]interface{})
err = rs.ms.Unmarshal(qVal, qMap)
if err != nil {
t.Fatalf("Run: %d, could not retrieve key %s, error: %s", idx, key, err.Error())
}
if idx == 0 { // Only compare at second iteration, first one is to set reference value
refVal = qVal
refMap = qMap
continue
}
if len(refVal) != len(qVal) {
t.Errorf("Missmatched data for key: %s\n\t reference val: %s \n\t retrieved val: %s\n on iteration: %d", key, refVal, qVal, idx)
if !reflect.DeepEqual(refMap, qVal) {
t.Errorf("Missmatched data for key: %s\n\t reference val: %+v \n\t retrieved val: %+v\n on iteration: %d", key, refMap, qMap, idx)
}
}
}