Make persistence.CreateTestDB public so it can be used from other packages

This commit is contained in:
Sybren A. Stüvel 2022-02-01 10:57:33 +01:00
parent 2ca8858c28
commit 862ed96af7
3 changed files with 5 additions and 5 deletions

View File

@ -31,7 +31,7 @@ import (
) )
func TestStoreAuthoredJob(t *testing.T) { func TestStoreAuthoredJob(t *testing.T) {
db := createTestDB(t) db := CreateTestDB(t)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel() defer cancel()

View File

@ -30,14 +30,14 @@ import (
"gorm.io/gorm" "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. // Creating a new database should be fast.
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel() defer cancel()
db, err := openDB(ctx, testURI) db, err := openDB(ctx, TestDSN)
assert.NoError(t, err) assert.NoError(t, err)
// Erase everything in the database. // Erase everything in the database.

View File

@ -32,7 +32,7 @@ import (
) )
func TestCreateFetchWorker(t *testing.T) { func TestCreateFetchWorker(t *testing.T) {
db := createTestDB(t) db := CreateTestDB(t)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel() defer cancel()