From 458d66d08feeac0c60b96f716d4bf4ae48e5ab4d Mon Sep 17 00:00:00 2001 From: porosnicuadrian Date: Fri, 10 Dec 2021 11:04:32 +0200 Subject: [PATCH] Updated routes code + tests --- engine/model_helpers_test.go | 5 +++-- engine/routes.go | 10 ++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/engine/model_helpers_test.go b/engine/model_helpers_test.go index 25dce9f58..74ee55314 100644 --- a/engine/model_helpers_test.go +++ b/engine/model_helpers_test.go @@ -853,8 +853,9 @@ func TestTPFilterAsTPFilter3(t *testing.T) { } rcvTPs := FilterMdls(tps).AsTPFilter() - sort.Strings(rcvTPs[0].Filters[0].Values) - sort.Strings(eTPs[0].Filters[0].Values) + sort.Slice(rcvTPs, func(i, j int) bool { + return rcvTPs[i].Tenant > rcvTPs[j].Tenant + }) if !reflect.DeepEqual(eTPs, rcvTPs) { t.Errorf("Expecting: %+v \n ,Received: %+v", utils.ToJSON(eTPs), utils.ToJSON(rcvTPs)) } diff --git a/engine/routes.go b/engine/routes.go index a61541654..e49df9b56 100644 --- a/engine/routes.go +++ b/engine/routes.go @@ -388,13 +388,11 @@ func (rpS *RouteS) sortedRoutesForEvent(ctx *context.Context, tnt string, args * prfCount := len(rPrfs) // if the option is not present return for all profiles var prfCountOpt *int if prfCountOpt, err = GetIntPointerOpts(ctx, tnt, args, rpS.fltrS, rpS.cfg.RouteSCfg().Opts.ProfileCount, - utils.OptsRoutesProfileCount); err != nil { - if err != utils.ErrNotFound { // if the error is NOT_FOUND, it means that in opts or config, countProfiles field is not defined, so we will get just 1 profile - return - } - prfCountOpt = utils.IntPointer(1) + utils.OptsRoutesProfileCount); err != nil && err != utils.ErrNotFound { + // if the error is NOT_FOUND, it means that in opts or config, countProfiles field is not defined + return } - if prfCountOpt != nil || prfCount > *prfCountOpt { // it has the option and is smaller that the current number of profiles + if prfCountOpt != nil && prfCount > *prfCountOpt { // it has the option and is smaller that the current number of profiles prfCount = *prfCountOpt } var extraOpts *optsGetRoutes