From 862ed96af7630bb5be85fdfc1751dd0c96cdf110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 1 Feb 2022 10:57:33 +0100 Subject: [PATCH] Make persistence.CreateTestDB public so it can be used from other packages --- internal/manager/persistence/jobs_test.go | 2 +- .../manager/persistence/{db_test.go => test_support.go} | 6 +++--- internal/manager/persistence/workers_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename internal/manager/persistence/{db_test.go => test_support.go} (93%) diff --git a/internal/manager/persistence/jobs_test.go b/internal/manager/persistence/jobs_test.go index c54e17ed..d95a8e9b 100644 --- a/internal/manager/persistence/jobs_test.go +++ b/internal/manager/persistence/jobs_test.go @@ -31,7 +31,7 @@ import ( ) func TestStoreAuthoredJob(t *testing.T) { - db := createTestDB(t) + db := CreateTestDB(t) ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) defer cancel() diff --git a/internal/manager/persistence/db_test.go b/internal/manager/persistence/test_support.go similarity index 93% rename from internal/manager/persistence/db_test.go rename to internal/manager/persistence/test_support.go index a9b4637f..ae36c01c 100644 --- a/internal/manager/persistence/db_test.go +++ b/internal/manager/persistence/test_support.go @@ -30,14 +30,14 @@ import ( "gorm.io/gorm" ) -const testURI = "host=localhost user=flamenco password=flamenco dbname=flamenco-test TimeZone=Europe/Amsterdam" +const TestDSN = "host=localhost user=flamenco password=flamenco dbname=flamenco-test TimeZone=Europe/Amsterdam" -func createTestDB(t *testing.T) *DB { +func CreateTestDB(t *testing.T) *DB { // Creating a new database should be fast. ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) defer cancel() - db, err := openDB(ctx, testURI) + db, err := openDB(ctx, TestDSN) assert.NoError(t, err) // Erase everything in the database. diff --git a/internal/manager/persistence/workers_test.go b/internal/manager/persistence/workers_test.go index 82c3268c..767d59db 100644 --- a/internal/manager/persistence/workers_test.go +++ b/internal/manager/persistence/workers_test.go @@ -32,7 +32,7 @@ import ( ) func TestCreateFetchWorker(t *testing.T) { - db := createTestDB(t) + db := CreateTestDB(t) ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) defer cancel()