Revise err handling for CSV storage constructor

NewFileCSVStorage() now returns an error besides the storage struct itself, which is
logged and returned instead of calling log.Fatal() which was causing the engine to
crash.

Fixed compilation errors by creating the CSVStorage separately and passing it as an
argument to the TpReader constructor.
This commit is contained in:
ionutboangiu
2023-05-22 07:10:07 -04:00
parent 12039b9d93
commit f2201f3e62
7 changed files with 47 additions and 16 deletions

View File

@@ -134,8 +134,11 @@ func testLoaderITRemoveLoad(t *testing.T) {
t.Error("Failed validating data: ", err.Error())
}
}*/
loader, err = NewTpReader(dataDbCsv, NewFileCSVStorage(utils.CSVSep,
path.Join(*dataDir, "tariffplans", *tpCsvScenario)), "", "",
csvStorage, err := NewFileCSVStorage(utils.CSVSep, path.Join(*dataDir, "tariffplans", *tpCsvScenario))
if err != nil {
t.Fatal(err)
}
loader, err = NewTpReader(dataDbCsv, csvStorage, "", "",
[]string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCaches)}, nil, false)
if err != nil {
t.Error(err)
@@ -213,8 +216,11 @@ func testLoaderITLoadFromCSV(t *testing.T) {
t.Error("Failed validating data: ", err.Error())
}
}*/
loader, err = NewTpReader(dataDbCsv, NewFileCSVStorage(utils.CSVSep,
path.Join(*dataDir, "tariffplans", *tpCsvScenario)), "", "",
csvStorage, err := NewFileCSVStorage(utils.CSVSep, path.Join(*dataDir, "tariffplans", *tpCsvScenario))
if err != nil {
t.Fatal(err)
}
loader, err = NewTpReader(dataDbCsv, csvStorage, "", "",
[]string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCaches)}, nil, false)
if err != nil {
t.Error(err)