Removed unused RemoveKeysForPrefix

This commit is contained in:
Trial97
2021-06-07 13:32:30 +03:00
committed by Dan Christian Bogos
parent b4d550a1d0
commit 421c193f6a
6 changed files with 18 additions and 72 deletions

View File

@@ -76,10 +76,6 @@ func (dbM *DataDBMock) GetKeysForPrefix(ctx *context.Context, prf string) ([]str
return nil, utils.ErrNotImplemented
}
func (dbM *DataDBMock) RemoveKeysForPrefix(string) error {
return utils.ErrNotImplemented
}
func (dbM *DataDBMock) GetVersions(itm string) (vrs Versions, err error) {
return nil, utils.ErrNotImplemented
}

View File

@@ -411,39 +411,6 @@ func (ms *MongoStorage) SelectDatabase(dbName string) (err error) {
return
}
func (ms *MongoStorage) RemoveKeysForPrefix(prefix string) (err error) {
var colName string
switch prefix {
case utils.LoadInstKey:
colName = ColLht
case utils.VersionPrefix:
colName = ColVer
case utils.ResourcesPrefix:
colName = ColRes
case utils.ResourceProfilesPrefix:
colName = ColRsP
case utils.ThresholdProfilePrefix:
colName = ColTps
case utils.StatQueueProfilePrefix:
colName = ColSqp
case utils.ThresholdPrefix:
colName = ColThs
case utils.FilterPrefix:
colName = ColFlt
case utils.RouteProfilePrefix:
colName = ColRts
case utils.AttributeProfilePrefix:
colName = ColAttr
default:
return utils.ErrInvalidKey
}
return ms.query(context.TODO(), func(sctx mongo.SessionContext) error {
_, err := ms.getCol(colName).DeleteMany(sctx, bson.M{})
return err
})
}
// IsDBEmpty implementation
func (ms *MongoStorage) IsDBEmpty() (resp bool, err error) {
err = ms.query(context.TODO(), func(sctx mongo.SessionContext) error {

View File

@@ -196,19 +196,6 @@ func (rs *RedisStorage) IsDBEmpty() (resp bool, err error) {
return true, nil
}
func (rs *RedisStorage) RemoveKeysForPrefix(prefix string) (err error) {
var keys []string
if keys, err = rs.GetKeysForPrefix(context.TODO(), prefix); err != nil {
return
}
for _, key := range keys {
if err = rs.Cmd(nil, redisDEL, key); err != nil {
return
}
}
return
}
func (rs *RedisStorage) getKeysForFilterIndexesKeys(fkeys []string) (keys []string, err error) {
for _, itemIDPrefix := range fkeys {
mp := make(map[string]string)

View File

@@ -75,10 +75,6 @@ func (sqls *SQLStorage) GetKeysForPrefix(ctx *context.Context, prefix string) ([
return nil, utils.ErrNotImplemented
}
func (SQLStorage) RemoveKeysForPrefix(string) error {
return utils.ErrNotImplemented
}
func (sqls *SQLStorage) CreateTablesFromScript(scriptPath string) error {
fileContent, err := os.ReadFile(scriptPath)
if err != nil {

View File

@@ -1050,7 +1050,7 @@ func TestThresholdsUpdateThreshold(t *testing.T) {
t.Errorf("Expected: %s, received: %s", utils.ToJSON(expTh), utils.ToJSON(th))
}
if err := dm.RemoveThreshold(context.Background(), th.Tenant, th.ID, ); err != nil {
if err := dm.RemoveThreshold(context.Background(), th.Tenant, th.ID); err != nil {
t.Fatal(err)
}
if err := dm.SetThresholdProfile(context.Background(), thp, true); err != nil {
@@ -1122,7 +1122,7 @@ func TestThresholdsUpdateThreshold(t *testing.T) {
} else if !reflect.DeepEqual(expTh, th) {
t.Errorf("Expected: %s, received: %s", utils.ToJSON(expTh), utils.ToJSON(th))
}
if err := dm.RemoveThresholdProfile(context.Background(), thp.Tenant, thp.ID, true); err != nil {
if err := dm.RemoveThresholdProfile(context.Background(), thp.Tenant, thp.ID, true); err != nil {
t.Fatal(err)
}
if _, err := dm.GetThreshold(context.Background(), thp.Tenant, thp.ID, false, false, utils.NonTransactional); err != utils.ErrNotFound {

View File

@@ -299,24 +299,24 @@ func testdoubleRemoveActionPlan(t *testing.T) {
} else if len(aps) != 1 {
t.Errorf("Expected: %v,\n received: %v", 1, len(aps))
} else if aps[0].Id != "ATMS_1" {
// remove
if err := sesRPC.Call(utils.APIerSv1RemoveActionPlan, &v1.AttrGetActionPlan{
ID: "ATMS_1"}, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
t.Error("Unexpected reply returned", reply)
}
//check again
/*
this should return ErrNotFound, right now it returns nil and an empty slice,
needs to be reviewed.
if err := sesRPC.Call(utils.APIerSv1GetActionPlan,
v1.AttrGetActionPlan{ID: utils.EmptyString}, &aps); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Errorf("Error: %+v, rcv: %+v", err, utils.ToJSON(aps))
// remove
if err := sesRPC.Call(utils.APIerSv1RemoveActionPlan, &v1.AttrGetActionPlan{
ID: "ATMS_1"}, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
t.Error("Unexpected reply returned", reply)
}
*/
//check again
/*
this should return ErrNotFound, right now it returns nil and an empty slice,
needs to be reviewed.
if err := sesRPC.Call(utils.APIerSv1GetActionPlan,
v1.AttrGetActionPlan{ID: utils.EmptyString}, &aps); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Errorf("Error: %+v, rcv: %+v", err, utils.ToJSON(aps))
}
*/
}
}
func testdoubleRemoveKillEngine(t *testing.T) {