Updated routes code + tests

This commit is contained in:
porosnicuadrian
2021-12-10 11:04:32 +02:00
committed by Dan Christian Bogos
parent 739190d08f
commit 458d66d08f
2 changed files with 7 additions and 8 deletions

View File

@@ -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))
}

View File

@@ -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