Make persistence.CreateTestDB public so it can be used from other packages
This commit is contained in:
parent
2ca8858c28
commit
862ed96af7
@ -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()
|
||||||
|
@ -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.
|
@ -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()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user