mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Fix RemoveProfile tests for resources, stats and thresholds
This commit is contained in:
committed by
Dan Christian Bogos
parent
e7061d9ba4
commit
7a928d6608
@@ -292,6 +292,9 @@ func TestResourcesRemoveResourceProfileCheckErrors(t *testing.T) {
|
||||
SetIndexesDrvF: func(ctx *context.Context, idxItmType, tntCtx string, indexes map[string]utils.StringSet, commit bool, transactionID string) (err error) {
|
||||
return nil
|
||||
},
|
||||
RemoveResourceDrvF: func(ctx *context.Context, tnt, id string) error {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
adms.dm = engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
|
||||
@@ -479,20 +482,9 @@ func TestResourcesSv1Ping(t *testing.T) {
|
||||
// },
|
||||
// }
|
||||
|
||||
// rs := &engine.Resource{
|
||||
// Tenant: "cgrates.org",
|
||||
// ID: "R_1",
|
||||
// Usages: map[string]*engine.ResourceUsage{
|
||||
// "RU_Test": {
|
||||
// Tenant: "cgrates.org",
|
||||
// ID: "RU_Test",
|
||||
// Units: 10,
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
// ttl := utils.DurationPointer(10 * time.Second)
|
||||
|
||||
// if err := dm.SetResource(context.Background(), rs, ttl, 1000, true); err != nil {
|
||||
// var reply string
|
||||
// if err := adms.SetResourceProfile(context.Background(), resPrf,
|
||||
// &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
|
||||
@@ -506,16 +498,63 @@ func TestResourcesSv1Ping(t *testing.T) {
|
||||
// },
|
||||
// UsageID: "RU_Test",
|
||||
// }
|
||||
// var result engine.Resources
|
||||
|
||||
// expRes := &engine.Resources{}
|
||||
// expResources := &engine.Resources{
|
||||
// {
|
||||
// Tenant: "cgrates.org",
|
||||
// ID: "TestResourcesGetResourcesForEvent",
|
||||
// Usages: make(map[string]*engine.ResourceUsage),
|
||||
// },
|
||||
// }
|
||||
|
||||
// if err := resSv1.GetResourcesForEvent(context.Background(), args, &result); err != nil {
|
||||
// var rplyResources engine.Resources
|
||||
// if err := resSv1.GetResourcesForEvent(context.Background(), args, &rplyResources); err != nil {
|
||||
// t.Error(err)
|
||||
// } else {
|
||||
// rplyPtr := &result
|
||||
// if !reflect.DeepEqual(expRes, rplyPtr) {
|
||||
// t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", utils.ToJSON(expRes), utils.ToJSON(rplyPtr))
|
||||
// rplyPtr := &rplyResources
|
||||
// if !reflect.DeepEqual(expResources, rplyPtr) {
|
||||
// t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(expResources), utils.ToJSON(rplyPtr))
|
||||
// }
|
||||
// }
|
||||
|
||||
// expResource := &engine.Resource{
|
||||
// Tenant: "cgrates.org",
|
||||
// ID: "TestResourcesGetResourcesForEvent",
|
||||
// Usages: make(map[string]*engine.ResourceUsage),
|
||||
// }
|
||||
|
||||
// var rplyResource engine.Resource
|
||||
// if err := resSv1.GetResource(context.Background(), &utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{
|
||||
// Tenant: "cgrates.org",
|
||||
// ID: "TestResourcesGetResourcesForEvent",
|
||||
// }}, &rplyResource); err != nil {
|
||||
// t.Error(err)
|
||||
// } else {
|
||||
// rplyPtr := &rplyResource
|
||||
// if !reflect.DeepEqual(expResource, rplyPtr) {
|
||||
// t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(expResource), utils.ToJSON(rplyPtr))
|
||||
// }
|
||||
// }
|
||||
|
||||
// expResourceWithCfg := &engine.ResourceWithConfig{
|
||||
// Resource: &engine.Resource{
|
||||
// Tenant: "cgrates.org",
|
||||
// ID: "TestResourcesGetResourcesForEvent",
|
||||
// Usages: make(map[string]*engine.ResourceUsage),
|
||||
// },
|
||||
// Config: resPrf.ResourceProfile,
|
||||
// }
|
||||
|
||||
// var rplyResourceWithCfg engine.ResourceWithConfig
|
||||
// if err := resSv1.GetResourceWithConfig(context.Background(), &utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{
|
||||
// Tenant: "cgrates.org",
|
||||
// ID: "TestResourcesGetResourcesForEvent",
|
||||
// }}, &rplyResourceWithCfg); err != nil {
|
||||
// t.Error(err)
|
||||
// } else {
|
||||
// rplyPtr := &rplyResourceWithCfg
|
||||
// if !reflect.DeepEqual(expResource, rplyPtr) {
|
||||
// t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(expResourceWithCfg), utils.ToJSON(rplyPtr))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -289,6 +289,9 @@ func TestStatsRemoveStatQueueProfileCheckErrors(t *testing.T) {
|
||||
SetIndexesDrvF: func(ctx *context.Context, idxItmType, tntCtx string, indexes map[string]utils.StringSet, commit bool, transactionID string) (err error) {
|
||||
return nil
|
||||
},
|
||||
RemStatQueueDrvF: func(ctx *context.Context, tenant, id string) (err error) {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
adms.dm = engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
|
||||
|
||||
@@ -291,6 +291,9 @@ func TestThresholdsRemoveThresholdProfileCheckErrors(t *testing.T) {
|
||||
SetIndexesDrvF: func(ctx *context.Context, idxItmType, tntCtx string, indexes map[string]utils.StringSet, commit bool, transactionID string) (err error) {
|
||||
return nil
|
||||
},
|
||||
RemoveThresholdDrvF: func(ctx *context.Context, tnt, id string) error {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
adms.dm = engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
|
||||
|
||||
@@ -40,12 +40,15 @@ type DataDBMock struct {
|
||||
SetThresholdProfileDrvF func(ctx *context.Context, tp *ThresholdProfile) (err error)
|
||||
RemThresholdProfileDrvF func(ctx *context.Context, tenant, id string) (err error)
|
||||
GetThresholdDrvF func(ctx *context.Context, tenant, id string) (*Threshold, error)
|
||||
RemoveThresholdDrvF func(ctx *context.Context, tnt, id string) error
|
||||
GetResourceProfileDrvF func(ctx *context.Context, tnt, id string) (*ResourceProfile, error)
|
||||
SetResourceProfileDrvF func(ctx *context.Context, rp *ResourceProfile) error
|
||||
RemoveResourceProfileDrvF func(ctx *context.Context, tnt, id string) error
|
||||
RemoveResourceDrvF func(ctx *context.Context, tnt, id string) error
|
||||
GetStatQueueProfileDrvF func(ctx *context.Context, tenant, id string) (sq *StatQueueProfile, err error)
|
||||
SetStatQueueProfileDrvF func(ctx *context.Context, sq *StatQueueProfile) (err error)
|
||||
RemStatQueueProfileDrvF func(ctx *context.Context, tenant, id string) (err error)
|
||||
RemStatQueueDrvF func(ctx *context.Context, tenant, id string) (err error)
|
||||
SetFilterDrvF func(ctx *context.Context, fltr *Filter) error
|
||||
GetActionProfileDrvF func(ctx *context.Context, tenant string, ID string) (*ActionProfile, error)
|
||||
SetActionProfileDrvF func(ctx *context.Context, ap *ActionProfile) error
|
||||
@@ -128,7 +131,10 @@ func (dbM *DataDBMock) SetResourceDrv(*context.Context, *Resource) error {
|
||||
return utils.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (dbM *DataDBMock) RemoveResourceDrv(*context.Context, string, string) error {
|
||||
func (dbM *DataDBMock) RemoveResourceDrv(ctx *context.Context, tnt, id string) error {
|
||||
if dbM.RemoveResourceDrvF != nil {
|
||||
return dbM.RemoveResourceDrvF(ctx, tnt, id)
|
||||
}
|
||||
return utils.ErrNotImplemented
|
||||
}
|
||||
|
||||
@@ -189,6 +195,9 @@ func (dbM *DataDBMock) SetStatQueueDrv(ctx *context.Context, ssq *StoredStatQueu
|
||||
}
|
||||
|
||||
func (dbM *DataDBMock) RemStatQueueDrv(ctx *context.Context, tenant, id string) (err error) {
|
||||
if dbM.RemStatQueueDrvF != nil {
|
||||
return dbM.RemStatQueueDrvF(ctx, tenant, id)
|
||||
}
|
||||
return utils.ErrNotImplemented
|
||||
}
|
||||
|
||||
@@ -224,7 +233,10 @@ func (dbM *DataDBMock) SetThresholdDrv(*context.Context, *Threshold) error {
|
||||
return utils.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (dbM *DataDBMock) RemoveThresholdDrv(*context.Context, string, string) error {
|
||||
func (dbM *DataDBMock) RemoveThresholdDrv(ctx *context.Context, tnt, id string) error {
|
||||
if dbM.RemoveThresholdDrvF != nil {
|
||||
return dbM.RemoveThresholdDrvF(ctx, tnt, id)
|
||||
}
|
||||
return utils.ErrNotImplemented
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user