From bdeb9d94243d57d07f480b29d48795e0e572c08d Mon Sep 17 00:00:00 2001
From: Ergin Babani <ergin@tenkeylabs.com>
Date: Mon, 8 Jan 2024 00:06:12 -0500
Subject: [PATCH] Close connection to base DB after cleanup

When running multiple quick tests in parallel it's possible to get a connection failure due to too many clients connected.
---
 testdb.go | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/testdb.go b/testdb.go
index f1819f8..2f8e4b6 100644
--- a/testdb.go
+++ b/testdb.go
@@ -154,6 +154,8 @@ func create(t testing.TB, conf Config, migrator Migrator) (*Config, *sql.DB) {
 	}
 
 	t.Cleanup(func() {
+		defer baseDB.Close()
+
 		// Close the testDB
 		if err := db.Close(); err != nil {
 			t.Fatalf("could not close test database: '%s': %s", instance.Database, err)