close db connections in test flush helpers

Previously, database connections would stay alive until "go test"
would finish, sometimes leading to max conn errors.
This commit is contained in:
ionutboangiu
2025-05-26 21:15:35 +03:00
committed by Dan Christian Bogos
parent 427c6aef10
commit 0feda9e993

View File

@@ -292,6 +292,7 @@ func InitDataDb(cfg *config.CGRConfig) error {
if err != nil {
return err
}
defer d.Close()
dm := NewDataManager(d, cfg.CacheCfg(), connMgr)
if err := dm.DataDB().Flush(""); err != nil {
@@ -315,6 +316,7 @@ func InitStorDb(cfg *config.CGRConfig) error {
if err != nil {
return err
}
defer storDb.Close()
db_Path := strings.Trim(cfg.StorDbCfg().Type, "*")
if err := storDb.Flush(path.Join(cfg.DataFolderPath, "storage",
db_Path)); err != nil {