mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated tests and methods for resourcesv1 with tenant default value
This commit is contained in:
committed by
Dan Christian Bogos
parent
b0e9c1aa26
commit
cbc3151a95
@@ -378,9 +378,13 @@ func testAttributeSProcessEvent(t *testing.T) {
|
||||
if err := attrSRPC.Call(utils.AttributeSv1ProcessEvent,
|
||||
ev, &rplyEv); err != nil {
|
||||
t.Error(err)
|
||||
} else if sort.Strings(eRply.AlteredFields); !reflect.DeepEqual(eRply, &rplyEv) { // second for reversed order of attributes
|
||||
t.Errorf("Expecting: %s, received: %s",
|
||||
utils.ToJSON(eRply), utils.ToJSON(rplyEv))
|
||||
} else {
|
||||
sort.Strings(eRply.AlteredFields)
|
||||
sort.Strings(rplyEv.AlteredFields)
|
||||
if !reflect.DeepEqual(eRply, &rplyEv) { // second for reversed order of attributes
|
||||
t.Errorf("Expecting: %s, received: %s",
|
||||
utils.ToJSON(eRply), utils.ToJSON(rplyEv))
|
||||
}
|
||||
}
|
||||
|
||||
ev.Tenant = ""
|
||||
@@ -389,9 +393,13 @@ func testAttributeSProcessEvent(t *testing.T) {
|
||||
if err := attrSRPC.Call(utils.AttributeSv1ProcessEvent,
|
||||
ev, &rplyEv); err != nil {
|
||||
t.Error(err)
|
||||
} else if sort.Strings(eRply.AlteredFields); !reflect.DeepEqual(eRply, &rplyEv) { // second for reversed order of attributes
|
||||
t.Errorf("Expecting: %s, received: %s",
|
||||
utils.ToJSON(eRply), utils.ToJSON(rplyEv))
|
||||
} else {
|
||||
sort.Strings(eRply.AlteredFields)
|
||||
sort.Strings(rplyEv.AlteredFields)
|
||||
if !reflect.DeepEqual(eRply, &rplyEv) { // second for reversed order of attributes
|
||||
t.Errorf("Expecting: %s, received: %s",
|
||||
utils.ToJSON(eRply), utils.ToJSON(rplyEv))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1333,6 +1333,17 @@ func testV1FIdxCaGetResourceProfileWithNotFound(t *testing.T) {
|
||||
&argsRU, &reply); err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
argsRU.Tenant = utils.EmptyString
|
||||
if err := tFIdxCaRpc.Call(utils.ResourceSv1AllocateResources,
|
||||
argsRU, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
if err := tFIdxCaRpc.Call(utils.ResourceSv1AuthorizeResources,
|
||||
&argsRU, &reply); err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
}
|
||||
func testV1FIdxCaSetResourceProfile(t *testing.T) {
|
||||
filter = &FilterWithCache{
|
||||
|
||||
@@ -317,6 +317,13 @@ func testInternalRemoteITGetResource(t *testing.T) {
|
||||
} else if !reflect.DeepEqual(reply, expectedResources) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(expectedResources), utils.ToJSON(reply))
|
||||
}
|
||||
|
||||
if err := internalRPC.Call(utils.ResourceSv1GetResource,
|
||||
&utils.TenantIDWithOpts{TenantID: &utils.TenantID{ID: "ResGroup1"}}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(reply, expectedResources) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(expectedResources), utils.ToJSON(reply))
|
||||
}
|
||||
}
|
||||
|
||||
func testInternalRemoteITGetResourceProfile(t *testing.T) {
|
||||
|
||||
@@ -197,6 +197,18 @@ func testV1RsGetResourcesForEvent(t *testing.T) {
|
||||
if (*reply)[0].ID != "ResGroup2" {
|
||||
t.Errorf("Expecting: %+v, received: %+v", "ResGroup2", (*reply)[0].ID)
|
||||
}
|
||||
|
||||
args.CGREvent.Tenant = utils.EmptyString
|
||||
args.CGREvent.ID = utils.UUIDSha1Prefix()
|
||||
if err := rlsV1Rpc.Call(utils.ResourceSv1GetResourcesForEvent, args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if len(*reply) != 1 {
|
||||
t.Errorf("Expecting: %+v, received: %+v", 1, len(*reply))
|
||||
}
|
||||
if (*reply)[0].ID != "ResGroup2" {
|
||||
t.Errorf("Expecting: %+v, received: %+v", "ResGroup2", (*reply)[0].ID)
|
||||
}
|
||||
}
|
||||
|
||||
func testV1RsTTL0(t *testing.T) {
|
||||
@@ -317,6 +329,12 @@ func testV1RsTTL0(t *testing.T) {
|
||||
argsRU, &releaseReply); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
argsRU.Tenant = utils.EmptyString
|
||||
if err := rlsV1Rpc.Call(utils.ResourceSv1ReleaseResources,
|
||||
argsRU, &releaseReply); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testV1RsAllocateResource(t *testing.T) {
|
||||
|
||||
@@ -466,7 +466,7 @@ func (rS *ResourceService) processThresholds(r *Resource, opts map[string]interf
|
||||
}
|
||||
|
||||
// matchingResourcesForEvent returns ordered list of matching resources which are active by the time of the call
|
||||
func (rS *ResourceService) matchingResourcesForEvent(ev *utils.CGREventWithOpts,
|
||||
func (rS *ResourceService) matchingResourcesForEvent(tnt string, ev *utils.CGREventWithOpts,
|
||||
evUUID string, usageTTL *time.Duration) (rs Resources, err error) {
|
||||
matchingResources := make(map[string]*Resource)
|
||||
var isCached bool
|
||||
@@ -486,7 +486,7 @@ func (rS *ResourceService) matchingResourcesForEvent(ev *utils.CGREventWithOpts,
|
||||
rS.cgrcfg.ResourceSCfg().StringIndexedFields,
|
||||
rS.cgrcfg.ResourceSCfg().PrefixIndexedFields,
|
||||
rS.cgrcfg.ResourceSCfg().SuffixIndexedFields,
|
||||
rS.dm, utils.CacheResourceFilterIndexes, ev.Tenant,
|
||||
rS.dm, utils.CacheResourceFilterIndexes, tnt,
|
||||
rS.cgrcfg.ResourceSCfg().IndexedSelects,
|
||||
rS.cgrcfg.ResourceSCfg().NestedFields,
|
||||
)
|
||||
@@ -503,7 +503,7 @@ func (rS *ResourceService) matchingResourcesForEvent(ev *utils.CGREventWithOpts,
|
||||
guardian.Guardian.Guard(func() (gIface interface{}, gErr error) {
|
||||
for resName := range rIDs {
|
||||
var rPrf *ResourceProfile
|
||||
if rPrf, err = rS.dm.GetResourceProfile(ev.Tenant, resName,
|
||||
if rPrf, err = rS.dm.GetResourceProfile(tnt, resName,
|
||||
true, true, utils.NonTransactional); err != nil {
|
||||
if err == utils.ErrNotFound {
|
||||
continue
|
||||
@@ -514,7 +514,7 @@ func (rS *ResourceService) matchingResourcesForEvent(ev *utils.CGREventWithOpts,
|
||||
!rPrf.ActivationInterval.IsActiveAtTime(*ev.Time) { // not active
|
||||
continue
|
||||
}
|
||||
if pass, err := rS.filterS.Pass(ev.Tenant, rPrf.FilterIDs,
|
||||
if pass, err := rS.filterS.Pass(tnt, rPrf.FilterIDs,
|
||||
evNm); err != nil {
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
@@ -574,15 +574,19 @@ func (rS *ResourceService) V1ResourcesForEvent(args utils.ArgRSv1ResourceUsage,
|
||||
if args.CGREvent == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.Event)
|
||||
}
|
||||
if missing := utils.MissingStructFields(args.CGREvent, []string{utils.Tenant, utils.ID, utils.Event}); len(missing) != 0 { //Params missing
|
||||
if missing := utils.MissingStructFields(args.CGREvent, []string{utils.ID, utils.Event}); len(missing) != 0 { //Params missing
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
} else if args.UsageID == "" {
|
||||
return utils.NewErrMandatoryIeMissing(utils.UsageID)
|
||||
}
|
||||
tnt := args.Tenant
|
||||
if tnt == utils.EmptyString {
|
||||
tnt = rS.cgrcfg.GeneralCfg().DefaultTenant
|
||||
}
|
||||
|
||||
// RPC caching
|
||||
if config.CgrConfig().CacheCfg().Partitions[utils.CacheRPCResponses].Limit != 0 {
|
||||
cacheKey := utils.ConcatenatedKey(utils.ResourceSv1GetResourcesForEvent, args.TenantID())
|
||||
cacheKey := utils.ConcatenatedKey(utils.ResourceSv1GetResourcesForEvent, utils.ConcatenatedKey(tnt, args.ID))
|
||||
refID := guardian.Guardian.GuardIDs("",
|
||||
config.CgrConfig().GeneralCfg().LockingTimeout, cacheKey) // RPC caching needs to be atomic
|
||||
defer guardian.Guardian.UnguardIDs(refID)
|
||||
@@ -600,7 +604,7 @@ func (rS *ResourceService) V1ResourcesForEvent(args utils.ArgRSv1ResourceUsage,
|
||||
// end of RPC caching
|
||||
|
||||
var mtcRLs Resources
|
||||
if mtcRLs, err = rS.matchingResourcesForEvent(args.CGREventWithOpts, args.UsageID, args.UsageTTL); err != nil {
|
||||
if mtcRLs, err = rS.matchingResourcesForEvent(tnt, args.CGREventWithOpts, args.UsageID, args.UsageTTL); err != nil {
|
||||
return err
|
||||
}
|
||||
*reply = mtcRLs
|
||||
@@ -612,15 +616,19 @@ func (rS *ResourceService) V1AuthorizeResources(args utils.ArgRSv1ResourceUsage,
|
||||
if args.CGREvent == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.Event)
|
||||
}
|
||||
if missing := utils.MissingStructFields(args.CGREvent, []string{utils.Tenant, utils.ID, utils.Event}); len(missing) != 0 { //Params missing
|
||||
if missing := utils.MissingStructFields(args.CGREvent, []string{utils.ID, utils.Event}); len(missing) != 0 { //Params missing
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
} else if args.UsageID == "" {
|
||||
return utils.NewErrMandatoryIeMissing(utils.UsageID)
|
||||
}
|
||||
tnt := args.Tenant
|
||||
if tnt == utils.EmptyString {
|
||||
tnt = rS.cgrcfg.GeneralCfg().DefaultTenant
|
||||
}
|
||||
|
||||
// RPC caching
|
||||
if config.CgrConfig().CacheCfg().Partitions[utils.CacheRPCResponses].Limit != 0 {
|
||||
cacheKey := utils.ConcatenatedKey(utils.ResourceSv1AuthorizeResources, args.TenantID())
|
||||
cacheKey := utils.ConcatenatedKey(utils.ResourceSv1AuthorizeResources, utils.ConcatenatedKey(tnt, args.ID))
|
||||
refID := guardian.Guardian.GuardIDs("",
|
||||
config.CgrConfig().GeneralCfg().LockingTimeout, cacheKey) // RPC caching needs to be atomic
|
||||
defer guardian.Guardian.UnguardIDs(refID)
|
||||
@@ -638,13 +646,13 @@ func (rS *ResourceService) V1AuthorizeResources(args utils.ArgRSv1ResourceUsage,
|
||||
// end of RPC caching
|
||||
|
||||
var mtcRLs Resources
|
||||
if mtcRLs, err = rS.matchingResourcesForEvent(args.CGREventWithOpts, args.UsageID, args.UsageTTL); err != nil {
|
||||
if mtcRLs, err = rS.matchingResourcesForEvent(tnt, args.CGREventWithOpts, args.UsageID, args.UsageTTL); err != nil {
|
||||
return err
|
||||
}
|
||||
var alcMessage string
|
||||
if alcMessage, err = mtcRLs.allocateResource(
|
||||
&ResourceUsage{
|
||||
Tenant: args.CGREvent.Tenant,
|
||||
Tenant: tnt,
|
||||
ID: args.UsageID,
|
||||
Units: args.Units}, true); err != nil {
|
||||
if err == utils.ErrResourceUnavailable {
|
||||
@@ -661,15 +669,19 @@ func (rS *ResourceService) V1AllocateResource(args utils.ArgRSv1ResourceUsage, r
|
||||
if args.CGREvent == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.Event)
|
||||
}
|
||||
if missing := utils.MissingStructFields(args.CGREvent, []string{utils.Tenant, utils.ID, utils.Event}); len(missing) != 0 { //Params missing
|
||||
if missing := utils.MissingStructFields(args.CGREvent, []string{utils.ID, utils.Event}); len(missing) != 0 { //Params missing
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
} else if args.UsageID == "" {
|
||||
return utils.NewErrMandatoryIeMissing(utils.UsageID)
|
||||
}
|
||||
tnt := args.Tenant
|
||||
if tnt == utils.EmptyString {
|
||||
tnt = rS.cgrcfg.GeneralCfg().DefaultTenant
|
||||
}
|
||||
|
||||
// RPC caching
|
||||
if config.CgrConfig().CacheCfg().Partitions[utils.CacheRPCResponses].Limit != 0 {
|
||||
cacheKey := utils.ConcatenatedKey(utils.ResourceSv1AllocateResources, args.TenantID())
|
||||
cacheKey := utils.ConcatenatedKey(utils.ResourceSv1AllocateResources, utils.ConcatenatedKey(tnt, args.ID))
|
||||
refID := guardian.Guardian.GuardIDs("",
|
||||
config.CgrConfig().GeneralCfg().LockingTimeout, cacheKey) // RPC caching needs to be atomic
|
||||
defer guardian.Guardian.UnguardIDs(refID)
|
||||
@@ -687,14 +699,14 @@ func (rS *ResourceService) V1AllocateResource(args utils.ArgRSv1ResourceUsage, r
|
||||
// end of RPC caching
|
||||
|
||||
var mtcRLs Resources
|
||||
if mtcRLs, err = rS.matchingResourcesForEvent(args.CGREventWithOpts, args.UsageID,
|
||||
if mtcRLs, err = rS.matchingResourcesForEvent(tnt, args.CGREventWithOpts, args.UsageID,
|
||||
args.UsageTTL); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var alcMsg string
|
||||
if alcMsg, err = mtcRLs.allocateResource(
|
||||
&ResourceUsage{Tenant: args.CGREvent.Tenant, ID: args.UsageID,
|
||||
&ResourceUsage{Tenant: tnt, ID: args.UsageID,
|
||||
Units: args.Units}, false); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -728,15 +740,19 @@ func (rS *ResourceService) V1ReleaseResource(args utils.ArgRSv1ResourceUsage, re
|
||||
if args.CGREvent == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.Event)
|
||||
}
|
||||
if missing := utils.MissingStructFields(args.CGREvent, []string{utils.Tenant, utils.ID, utils.Event}); len(missing) != 0 { //Params missing
|
||||
if missing := utils.MissingStructFields(args.CGREvent, []string{utils.ID, utils.Event}); len(missing) != 0 { //Params missing
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
} else if args.UsageID == "" {
|
||||
return utils.NewErrMandatoryIeMissing(utils.UsageID)
|
||||
}
|
||||
tnt := args.Tenant
|
||||
if tnt == utils.EmptyString {
|
||||
tnt = rS.cgrcfg.GeneralCfg().DefaultTenant
|
||||
}
|
||||
|
||||
// RPC caching
|
||||
if config.CgrConfig().CacheCfg().Partitions[utils.CacheRPCResponses].Limit != 0 {
|
||||
cacheKey := utils.ConcatenatedKey(utils.ResourceSv1ReleaseResources, args.TenantID())
|
||||
cacheKey := utils.ConcatenatedKey(utils.ResourceSv1ReleaseResources, utils.ConcatenatedKey(tnt, args.ID))
|
||||
refID := guardian.Guardian.GuardIDs("",
|
||||
config.CgrConfig().GeneralCfg().LockingTimeout, cacheKey) // RPC caching needs to be atomic
|
||||
defer guardian.Guardian.UnguardIDs(refID)
|
||||
@@ -754,7 +770,7 @@ func (rS *ResourceService) V1ReleaseResource(args utils.ArgRSv1ResourceUsage, re
|
||||
// end of RPC caching
|
||||
|
||||
var mtcRLs Resources
|
||||
if mtcRLs, err = rS.matchingResourcesForEvent(args.CGREventWithOpts, args.UsageID,
|
||||
if mtcRLs, err = rS.matchingResourcesForEvent(tnt, args.CGREventWithOpts, args.UsageID,
|
||||
args.UsageTTL); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -789,10 +805,14 @@ func (rS *ResourceService) V1ReleaseResource(args utils.ArgRSv1ResourceUsage, re
|
||||
|
||||
// V1GetResource returns a resource configuration
|
||||
func (rS *ResourceService) V1GetResource(arg *utils.TenantIDWithOpts, reply *Resource) error {
|
||||
if missing := utils.MissingStructFields(arg, []string{"Tenant", "ID"}); len(missing) != 0 { //Params missing
|
||||
if missing := utils.MissingStructFields(arg, []string{utils.ID}); len(missing) != 0 { //Params missing
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
}
|
||||
res, err := rS.dm.GetResource(arg.Tenant, arg.ID, true, true, utils.NonTransactional)
|
||||
tnt := arg.Tenant
|
||||
if tnt == utils.EmptyString {
|
||||
tnt = rS.cgrcfg.GeneralCfg().DefaultTenant
|
||||
}
|
||||
res, err := rS.dm.GetResource(tnt, arg.ID, true, true, utils.NonTransactional)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -385,7 +385,7 @@ func TestRoutesCache(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRoutesmatchingRouteProfilesForEvent(t *testing.T) {
|
||||
sprf, err := routeService.matchingRouteProfilesForEvent(argsGetRoutes[0].CGREventWithOpts, true)
|
||||
sprf, err := routeService.matchingRouteProfilesForEvent(argsGetRoutes[0].Tenant, argsGetRoutes[0].CGREventWithOpts, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -393,7 +393,7 @@ func TestRoutesmatchingRouteProfilesForEvent(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[0], sprf[0])
|
||||
}
|
||||
|
||||
sprf, err = routeService.matchingRouteProfilesForEvent(argsGetRoutes[1].CGREventWithOpts, true)
|
||||
sprf, err = routeService.matchingRouteProfilesForEvent(argsGetRoutes[1].Tenant, argsGetRoutes[1].CGREventWithOpts, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -401,7 +401,7 @@ func TestRoutesmatchingRouteProfilesForEvent(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[1], sprf[0])
|
||||
}
|
||||
|
||||
sprf, err = routeService.matchingRouteProfilesForEvent(argsGetRoutes[2].CGREventWithOpts, true)
|
||||
sprf, err = routeService.matchingRouteProfilesForEvent(argsGetRoutes[2].Tenant, argsGetRoutes[2].CGREventWithOpts, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -425,7 +425,7 @@ func TestRoutesSortedForEvent(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
sprf, err := routeService.sortedRoutesForEvent(argsGetRoutes[0])
|
||||
sprf, err := routeService.sortedRoutesForEvent(argsGetRoutes[0].Tenant, argsGetRoutes[0])
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -462,7 +462,7 @@ func TestRoutesSortedForEvent(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
sprf, err = routeService.sortedRoutesForEvent(argsGetRoutes[1])
|
||||
sprf, err = routeService.sortedRoutesForEvent(argsGetRoutes[1].Tenant, argsGetRoutes[1])
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -485,7 +485,7 @@ func TestRoutesSortedForEvent(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
sprf, err = routeService.sortedRoutesForEvent(argsGetRoutes[2])
|
||||
sprf, err = routeService.sortedRoutesForEvent(argsGetRoutes[2].Tenant, argsGetRoutes[2])
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -519,7 +519,7 @@ func TestRoutesSortedForEventWithLimit(t *testing.T) {
|
||||
argsGetRoutes[1].Paginator = utils.Paginator{
|
||||
Limit: utils.IntPointer(2),
|
||||
}
|
||||
sprf, err := routeService.sortedRoutesForEvent(argsGetRoutes[1])
|
||||
sprf, err := routeService.sortedRoutesForEvent(argsGetRoutes[1].Tenant, argsGetRoutes[1])
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -546,7 +546,7 @@ func TestRoutesSortedForEventWithOffset(t *testing.T) {
|
||||
argsGetRoutes[1].Paginator = utils.Paginator{
|
||||
Offset: utils.IntPointer(2),
|
||||
}
|
||||
sprf, err := routeService.sortedRoutesForEvent(argsGetRoutes[1])
|
||||
sprf, err := routeService.sortedRoutesForEvent(argsGetRoutes[1].Tenant, argsGetRoutes[1])
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -574,7 +574,7 @@ func TestRoutesSortedForEventWithLimitAndOffset(t *testing.T) {
|
||||
Limit: utils.IntPointer(1),
|
||||
Offset: utils.IntPointer(1),
|
||||
}
|
||||
sprf, err := routeService.sortedRoutesForEvent(argsGetRoutes[1])
|
||||
sprf, err := routeService.sortedRoutesForEvent(argsGetRoutes[1].Tenant, argsGetRoutes[1])
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -635,7 +635,7 @@ func TestRoutesAsOptsGetRoutesMaxCost(t *testing.T) {
|
||||
|
||||
func TestRoutesMatchWithIndexFalse(t *testing.T) {
|
||||
routeService.cgrcfg.RouteSCfg().IndexedSelects = false
|
||||
sprf, err := routeService.matchingRouteProfilesForEvent(argsGetRoutes[0].CGREventWithOpts, true)
|
||||
sprf, err := routeService.matchingRouteProfilesForEvent(argsGetRoutes[0].Tenant, argsGetRoutes[0].CGREventWithOpts, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -643,7 +643,7 @@ func TestRoutesMatchWithIndexFalse(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[0], sprf[0])
|
||||
}
|
||||
|
||||
sprf, err = routeService.matchingRouteProfilesForEvent(argsGetRoutes[1].CGREventWithOpts, true)
|
||||
sprf, err = routeService.matchingRouteProfilesForEvent(argsGetRoutes[1].Tenant, argsGetRoutes[1].CGREventWithOpts, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -651,7 +651,7 @@ func TestRoutesMatchWithIndexFalse(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sppTest[1], sprf[0])
|
||||
}
|
||||
|
||||
sprf, err = routeService.matchingRouteProfilesForEvent(argsGetRoutes[2].CGREventWithOpts, true)
|
||||
sprf, err = routeService.matchingRouteProfilesForEvent(argsGetRoutes[2].Tenant, argsGetRoutes[2].CGREventWithOpts, true)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ func TestResourceV1AuthorizeResourceMissingStruct(t *testing.T) {
|
||||
},
|
||||
Units: 20,
|
||||
}
|
||||
if err := resService.V1AuthorizeResources(argsMissingTenant, reply); err != nil && err.Error() != "MANDATORY_IE_MISSING: [Tenant Event]" {
|
||||
if err := resService.V1AuthorizeResources(argsMissingTenant, reply); err != nil && err.Error() != "MANDATORY_IE_MISSING: [Event]" {
|
||||
t.Error(err.Error())
|
||||
}
|
||||
if err := resService.V1AuthorizeResources(argsMissingUsageID, reply); err != nil && err.Error() != "MANDATORY_IE_MISSING: [Event]" {
|
||||
@@ -500,7 +500,7 @@ func TestResourceAddResourceProfile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResourceMatchingResourcesForEvent(t *testing.T) {
|
||||
mres, err := resService.matchingResourcesForEvent(resEvs[0],
|
||||
mres, err := resService.matchingResourcesForEvent(resEvs[0].Tenant, resEvs[0],
|
||||
"TestResourceMatchingResourcesForEvent1", &timeDurationExample)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
@@ -513,7 +513,7 @@ func TestResourceMatchingResourcesForEvent(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", resourceTest[0].rPrf, mres[0].rPrf)
|
||||
}
|
||||
|
||||
mres, err = resService.matchingResourcesForEvent(resEvs[1],
|
||||
mres, err = resService.matchingResourcesForEvent(resEvs[1].Tenant, resEvs[1],
|
||||
"TestResourceMatchingResourcesForEvent2", &timeDurationExample)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
@@ -526,7 +526,7 @@ func TestResourceMatchingResourcesForEvent(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", resourceTest[1].rPrf, mres[0].rPrf)
|
||||
}
|
||||
|
||||
mres, err = resService.matchingResourcesForEvent(resEvs[2],
|
||||
mres, err = resService.matchingResourcesForEvent(resEvs[2].Tenant, resEvs[2],
|
||||
"TestResourceMatchingResourcesForEvent3", &timeDurationExample)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
@@ -551,7 +551,7 @@ func TestResourceUsageTTLCase1(t *testing.T) {
|
||||
if err := dmRES.SetResource(resourceTest[0], nil, 0, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
mres, err := resService.matchingResourcesForEvent(resEvs[0],
|
||||
mres, err := resService.matchingResourcesForEvent(resEvs[0].Tenant, resEvs[0],
|
||||
"TestResourceUsageTTLCase1", &timeDurationExample)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
@@ -578,7 +578,7 @@ func TestResourceUsageTTLCase2(t *testing.T) {
|
||||
if err := dmRES.SetResource(resourceTest[0], nil, 0, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
mres, err := resService.matchingResourcesForEvent(resEvs[0],
|
||||
mres, err := resService.matchingResourcesForEvent(resEvs[0].Tenant, resEvs[0],
|
||||
"TestResourceUsageTTLCase2", nil)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
@@ -605,7 +605,7 @@ func TestResourceUsageTTLCase3(t *testing.T) {
|
||||
if err := dmRES.SetResource(resourceTest[0], nil, 0, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
mres, err := resService.matchingResourcesForEvent(resEvs[0],
|
||||
mres, err := resService.matchingResourcesForEvent(resEvs[0].Tenant, resEvs[0],
|
||||
"TestResourceUsageTTLCase3", utils.DurationPointer(time.Duration(0)))
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
@@ -632,7 +632,7 @@ func TestResourceUsageTTLCase4(t *testing.T) {
|
||||
if err := dmRES.SetResource(resourceTest[0], nil, 0, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
mres, err := resService.matchingResourcesForEvent(resEvs[0],
|
||||
mres, err := resService.matchingResourcesForEvent(resEvs[0].Tenant, resEvs[0],
|
||||
"TestResourceUsageTTLCase4", &timeDurationExample)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
@@ -650,7 +650,7 @@ func TestResourceUsageTTLCase4(t *testing.T) {
|
||||
|
||||
func TestResourceMatchWithIndexFalse(t *testing.T) {
|
||||
resService.cgrcfg.ResourceSCfg().IndexedSelects = false
|
||||
mres, err := resService.matchingResourcesForEvent(resEvs[0],
|
||||
mres, err := resService.matchingResourcesForEvent(resEvs[0].Tenant, resEvs[0],
|
||||
"TestResourceMatchWithIndexFalse1", &timeDurationExample)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
@@ -663,7 +663,7 @@ func TestResourceMatchWithIndexFalse(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", resourceTest[0].rPrf, mres[0].rPrf)
|
||||
}
|
||||
|
||||
mres, err = resService.matchingResourcesForEvent(resEvs[1],
|
||||
mres, err = resService.matchingResourcesForEvent(resEvs[1].Tenant, resEvs[1],
|
||||
"TestResourceMatchWithIndexFalse2", &timeDurationExample)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
@@ -676,7 +676,7 @@ func TestResourceMatchWithIndexFalse(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", resourceTest[1].rPrf, mres[0].rPrf)
|
||||
}
|
||||
|
||||
mres, err = resService.matchingResourcesForEvent(resEvs[2],
|
||||
mres, err = resService.matchingResourcesForEvent(resEvs[2].Tenant, resEvs[2],
|
||||
"TestResourceMatchWithIndexFalse3", &timeDurationExample)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
@@ -783,7 +783,7 @@ func TestResourceCaching(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
mres, err := resService.matchingResourcesForEvent(ev,
|
||||
mres, err := resService.matchingResourcesForEvent(ev.Tenant, ev,
|
||||
"TestResourceCaching", nil)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
|
||||
Reference in New Issue
Block a user