mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-13 02:56:24 +05:00
unmarshal test keys before comparison
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user