Updated test for filter indexes as dynbamicdp

This commit is contained in:
porosnicuadrian
2021-05-26 16:47:34 +03:00
committed by Dan Christian Bogos
parent f4c3afba33
commit 76476afeb7

View File

@@ -2296,6 +2296,7 @@ func TestFilterIndexesCheckingDynamicPathToNotIndex(t *testing.T) {
attrPrf1 := &AttributeProfile{
Tenant: "cgrates.org",
ID: "AttrPrf1",
Contexts: []string{utils.MetaAny},
FilterIDs: []string{"*string:~*req.Account:1001", "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z", "*string:~*opts.*context:con1|con2|con3"},
Attributes: []*Attribute{
{
@@ -2312,7 +2313,8 @@ func TestFilterIndexesCheckingDynamicPathToNotIndex(t *testing.T) {
attrPrf2 := &AttributeProfile{
Tenant: "cgrates.org",
ID: "AttrPrf2",
FilterIDs: []string{"*gte:~*resource.RES_GRP1.Available:~*stats.STS_PRF1.*tcc"},
Contexts: []string{utils.MetaAny},
FilterIDs: []string{"*string:~*resources.RES_GRP1.Available:4"},
Attributes: []*Attribute{
{
Path: utils.MetaReq + utils.NestingSep + "Password",
@@ -2327,7 +2329,8 @@ func TestFilterIndexesCheckingDynamicPathToNotIndex(t *testing.T) {
attrPrf3 := &AttributeProfile{
Tenant: "cgrates.org",
ID: "AttrPrf3",
FilterIDs: []string{"*prefix:~*req.Destination:1007", "*string:~*req.Account:1001", "*gte:~*opts.TotalCost:~*stats.STS_PRF1.*tcc"},
Contexts: []string{utils.MetaAny},
FilterIDs: []string{"*prefix:~*req.Destination:1007", "*string:~*req.Account:1001", "*string:~*opts.TotalCost:~*stats.STS_PRF1.*tcc"},
Attributes: []*Attribute{
{
Path: utils.MetaReq + utils.NestingSep + "RequestType",
@@ -2342,7 +2345,8 @@ func TestFilterIndexesCheckingDynamicPathToNotIndex(t *testing.T) {
attrPrf4 := &AttributeProfile{
Tenant: "cgrates.org",
ID: "AttrPrf4",
FilterIDs: []string{"*prefix:~*req.Destination:1007", "*lt:~*resource.RES_GRP1.Available:10"},
Contexts: []string{utils.MetaAny},
FilterIDs: []string{"*prefix:~*req.Destination:1007", "*prefix:~*accounts.RES_GRP1.Available:10"},
Attributes: []*Attribute{
{
Path: utils.MetaReq + utils.NestingSep + "TCC",
@@ -2354,13 +2358,13 @@ func TestFilterIndexesCheckingDynamicPathToNotIndex(t *testing.T) {
Weight: 20,
}
if err := dm.SetAttributeProfile(context.Background(), attrPrf1, true); err != nil {
if err := dm.SetAttributeProfile(attrPrf1, true); err != nil {
t.Error(err)
} else if err := dm.SetAttributeProfile(context.Background(), attrPrf2, true); err != nil {
} else if err := dm.SetAttributeProfile(attrPrf2, true); err != nil {
t.Error(err)
} else if err := dm.SetAttributeProfile(context.Background(), attrPrf3, true); err != nil {
} else if err := dm.SetAttributeProfile(attrPrf3, true); err != nil {
t.Error(err)
} else if err := dm.SetAttributeProfile(context.Background(), attrPrf4, true); err != nil {
} else if err := dm.SetAttributeProfile(attrPrf4, true); err != nil {
t.Error(err)
}
@@ -2383,8 +2387,8 @@ func TestFilterIndexesCheckingDynamicPathToNotIndex(t *testing.T) {
"AttrPrf1": {},
},
}
if fltrIDx, err := dm.GetIndexes(context.Background(), utils.CacheAttributeFilterIndexes,
"cgrates.org", utils.EmptyString, true, true); err != nil {
if fltrIDx, err := dm.GetIndexes(utils.CacheAttributeFilterIndexes,
"cgrates.org:*any", utils.EmptyString, true, true); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expIDx, fltrIDx) {
t.Errorf("Expected %+v, received %+v", utils.ToJSON(expIDx), utils.ToJSON(fltrIDx))