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/reader_test.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'pkg/datamaps/reader_test.go') diff --git a/pkg/datamaps/reader_test.go b/pkg/datamaps/reader_test.go index c221b26..53aff4a 100644 --- a/pkg/datamaps/reader_test.go +++ b/pkg/datamaps/reader_test.go @@ -1,6 +1,7 @@ package datamaps import ( + "os" "testing" ) @@ -73,7 +74,10 @@ func TestReadXLSX(t *testing.T) { // func TestExtractWithDBDatamap(t *testing.T) { // // setup - we need the datamap in the test database // 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.") @@ -95,7 +99,10 @@ func TestReadXLSX(t *testing.T) { func TestDMLSliceFromDatabase(t *testing.T) { // setup - we need the datamap in the test database 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.") @@ -142,7 +149,10 @@ func TestDMLSliceFromDatabase(t *testing.T) { func TestExtractUsingDBDM(t *testing.T) { // setup - we need the datamap in the test database 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