From ee8bc3a307a6108db7c4195a828381caf207614e Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Mon, 27 Jul 2020 07:22:26 +0100 Subject: improved defers --- pkg/datamaps/db_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'pkg/datamaps/db_test.go') diff --git a/pkg/datamaps/db_test.go b/pkg/datamaps/db_test.go index 2055d8a..3ca9054 100644 --- a/pkg/datamaps/db_test.go +++ b/pkg/datamaps/db_test.go @@ -1,12 +1,16 @@ package datamaps import ( + "os" "testing" ) func TestOpenSQLiteFile(t *testing.T) { db, err := setupDB("./testdata/test.db") - defer db.Close() + defer func() { + db.Close() + os.Remove("./testdata/test.db") + }() if err != nil { t.Fatal("Expected to be able to set up the database.") @@ -38,7 +42,10 @@ func TestOpenSQLiteFile(t *testing.T) { func TestDatamapGoesIntoDB(t *testing.T) { db, err := setupDB("./testdata/test.db") - defer db.Close() + defer func() { + db.Close() + os.Remove("./testdata/test.db") + }() if err != nil { t.Fatal("Expected to be able to set up the database.") -- cgit v1.2.3