7da57058d4
Bugfix/flakydb * init * fixenvvar * fixtest
36 lines
690 B
Go
36 lines
690 B
Go
package database_test
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path"
|
|
"queryorchestration/internal/database"
|
|
"queryorchestration/internal/test"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestRunMigrations(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
_, cleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{
|
|
NoPool: true,
|
|
})
|
|
defer cleanup()
|
|
|
|
database.RunMigrations(ctx, &database.MigrationConfig{
|
|
BasePath: path.Join(os.Getenv("PWD"), "../.."),
|
|
})
|
|
}
|
|
|
|
func TestRunMigrationsNoDB(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
assert.Panics(t, func() {
|
|
database.RunMigrations(ctx, &database.MigrationConfig{
|
|
BasePath: path.Join(os.Getenv("PWD"), "../.."),
|
|
})
|
|
})
|
|
}
|