diff --git a/pool/pool_test.go b/pool/pool_test.go index 475104f9..39d6f1ed 100644 --- a/pool/pool_test.go +++ b/pool/pool_test.go @@ -132,6 +132,17 @@ func TestPool(t *testing.T) { boltDB.Close() } + // Cleanup postgres DB from potential failed previous runs. + postgresDB, err := setupPostgresDB() + if err != nil { + t.Fatalf("setupPostgresDB error: %v", err) + } + err = postgresDB.purge() + if err != nil { + t.Fatalf("postgres teardown error: %v", err) + } + postgresDB.Close() + // Run all tests with postgres DB. for testName, test := range tests { if t.Failed() { @@ -147,9 +158,11 @@ func TestPool(t *testing.T) { t.Run(testName+"_Postgres", test) - err = postgresDB.purge() - if err != nil { - t.Fatalf("postgres teardown error: %v", err) + if !t.Failed() { + err = postgresDB.purge() + if err != nil { + t.Fatalf("postgres teardown error: %v", err) + } } postgresDB.Close()