From 76476afeb78393e65a565abc50018c4e92e0602b Mon Sep 17 00:00:00 2001 From: porosnicuadrian Date: Wed, 26 May 2021 16:47:34 +0300 Subject: [PATCH] Updated test for filter indexes as dynbamicdp --- engine/filters_test.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/engine/filters_test.go b/engine/filters_test.go index cc3fbcb41..7409d89a6 100644 --- a/engine/filters_test.go +++ b/engine/filters_test.go @@ -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))