fixed incorrect if breaking test db

This commit is contained in:
Nickiel12 2024-02-08 18:11:18 -08:00
parent dfdbf2b63e
commit dc0b37e564

View file

@ -26,17 +26,17 @@ func Init_testdb(DB_TYPE string, DB_CONNECTION_STRING string) {
log.Trace().Msgf("Currect working directory is: %s", cwd) log.Trace().Msgf("Currect working directory is: %s", cwd)
} }
_, err = os.Stat(cwd + DB_CONNECTION_STRING) _, err = os.Stat(cwd + DB_CONNECTION_STRING)
if err != nil { if err != nil {
log.Debug().Msg("Found existing test.db file. Attempting to delete")
err = os.Remove(DB_CONNECTION_STRING)
if err != nil {
log.Warn().Err(err).Msg("Failed to delete testing db. Continueing anyways")
} else {
log.Debug().Msg("Deleted test.db file successfully")
}
} else {
log.Debug().Msg("No existing test.db file found") log.Debug().Msg("No existing test.db file found")
} else {
log.Debug().Msg("Found existing test.db file. Attempting to delete")
err = os.Remove(cwd + DB_CONNECTION_STRING)
if err != nil {
log.Warn().Err(err).Msg("Failed to delete testing db. Continueing anyways")
} else {
log.Debug().Msg("Deleted test.db file successfully")
}
} }
db, err := sqlx.Connect(DB_TYPE, DB_CONNECTION_STRING) db, err := sqlx.Connect(DB_TYPE, DB_CONNECTION_STRING)