TestMain: Handle "defer" before os.Exit #5330

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-11-21 18:58:36 +01:00
parent 6c50a87632
commit d023139c12
17 changed files with 66 additions and 27 deletions

View File

@@ -22,7 +22,6 @@ func TestMain(m *testing.M) {
fs.PurgeTestDbFiles(".", false)
c := config.TestConfig()
defer c.CloseDb()
get.SetConfig(c)
photoprism.SetConfig(c)
@@ -30,6 +29,10 @@ func TestMain(m *testing.M) {
// Run unit tests.
code := m.Run()
if err := c.CloseDb(); err != nil {
log.Errorf("close db: %v", err)
}
// Remove temporary SQLite files after running the tests.
fs.PurgeTestDbFiles(".", false)