Fix failing tests after removal of Context from attributes

This commit is contained in:
ionutboangiu
2021-05-18 17:22:21 +03:00
committed by Dan Christian Bogos
parent 908412c430
commit 571b6bf19a
3 changed files with 18 additions and 8 deletions

View File

@@ -393,7 +393,7 @@ func TestLoadAttributeProfiles(t *testing.T) {
TPid: testTPID,
Tenant: "cgrates.org",
ID: "ALS1",
FilterIDs: []string{"*string:~*req.Account:1001", "*string:~*opts.*context:con1|con2|con3"},
FilterIDs: []string{"*string:~*opts.*context:con1", "*string:~*opts.*context:con2|con3", "*string:~*req.Account:1001"},
Attributes: []*utils.TPAttribute{
{
FilterIDs: []string{"*string:~*req.Field1:Initial"},
@@ -412,7 +412,9 @@ func TestLoadAttributeProfiles(t *testing.T) {
Weight: 20,
},
}
resKey := utils.TenantID{Tenant: "cgrates.org", ID: "ALS1"}
sort.Strings(csvr.attributeProfiles[resKey].FilterIDs)
if len(csvr.attributeProfiles) != len(eAttrProfiles) {
t.Errorf("Failed to load attributeProfiles: %s", utils.ToIJSON(csvr.attributeProfiles))
} else if !reflect.DeepEqual(eAttrProfiles[resKey].Tenant, csvr.attributeProfiles[resKey].Tenant) {

View File

@@ -441,7 +441,7 @@ func TestAttributeIndexer(t *testing.T) {
},
}
if rcvIdx, err := dmAtr.GetIndexes(context.TODO(), utils.CacheAttributeFilterIndexes,
utils.ConcatenatedKey(attrPrf.Tenant, utils.MetaAny), "", false, false); err != nil {
attrPrf.Tenant, "", false, false); err != nil {
t.Error(err)
} else {
if !reflect.DeepEqual(eIdxes, rcvIdx) {
@@ -456,17 +456,25 @@ func TestAttributeIndexer(t *testing.T) {
t.Error(err)
}
if rcvIdx, err := dmAtr.GetIndexes(context.TODO(), utils.CacheAttributeFilterIndexes,
utils.ConcatenatedKey(attrPrf.Tenant, utils.MetaSessionS), "", false, false); err != nil {
attrPrf.Tenant, "", false, false); err != nil {
t.Error(err)
} else {
if !reflect.DeepEqual(eIdxes, rcvIdx) {
t.Errorf("Expecting %+v, received: %+v", eIdxes, rcvIdx)
}
}
expected := map[string]utils.StringSet{
"*string:*opts.*context:*sessions": {
"AttrPrf": {},
},
}
//verify if old index was deleted ( context *any)
if _, err := dmAtr.GetIndexes(context.TODO(), utils.CacheAttributeFilterIndexes,
utils.ConcatenatedKey(attrPrf.Tenant, utils.MetaAny), "", false, false); err != utils.ErrNotFound {
if rcv, err := dmAtr.GetIndexes(context.TODO(), utils.CacheAttributeFilterIndexes,
attrPrf.Tenant, "", false, false); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(rcv, expected) {
t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", expected, rcv)
}
}

View File

@@ -188,15 +188,15 @@ func TestLoaderProcessContentMultiFiles(t *testing.T) {
{Tag: "Weight",
Path: "Weight",
Type: utils.MetaString,
Value: config.NewRSRParsersMustCompile("3", utils.InfieldSep)},
Value: config.NewRSRParsersMustCompile("10", utils.InfieldSep)},
{Tag: "Path",
Path: "Path",
Type: utils.MetaComposed,
Value: config.NewRSRParsersMustCompile("~*file(File1.csv).5", utils.InfieldSep)},
Value: config.NewRSRParsersMustCompile("~*file(File1.csv).6", utils.InfieldSep)},
{Tag: "Value",
Path: "Value",
Type: utils.MetaComposed,
Value: config.NewRSRParsersMustCompile("~*file(File1.csv).6", utils.InfieldSep)},
Value: config.NewRSRParsersMustCompile("~*file(File1.csv).7", utils.InfieldSep)},
},
}
rdr1 := io.NopCloser(strings.NewReader(file1CSV))