2024-12-24 18:11:25 +00:00
|
|
|
package database_test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"os"
|
|
|
|
|
"path"
|
|
|
|
|
"queryorchestration/internal/database"
|
2025-01-10 19:17:20 +00:00
|
|
|
"queryorchestration/internal/test"
|
2024-12-24 18:11:25 +00:00
|
|
|
"testing"
|
2025-01-08 18:14:15 +00:00
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2024-12-24 18:11:25 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestRunMigrations(t *testing.T) {
|
|
|
|
|
ctx := context.Background()
|
2025-01-10 19:17:20 +00:00
|
|
|
|
2025-01-15 12:19:49 +00:00
|
|
|
_, cleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{})
|
2025-01-10 11:12:03 +00:00
|
|
|
defer cleanup()
|
2024-12-24 18:11:25 +00:00
|
|
|
|
2025-01-10 19:17:20 +00:00
|
|
|
database.RunMigrations(ctx, &database.MigrationConfig{
|
2025-01-08 18:14:15 +00:00
|
|
|
BasePath: path.Join(os.Getenv("PWD"), "../.."),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestRunMigrationsNoDB(t *testing.T) {
|
2025-01-10 19:17:20 +00:00
|
|
|
ctx := context.Background()
|
|
|
|
|
|
2025-01-08 18:14:15 +00:00
|
|
|
assert.Panics(t, func() {
|
2025-01-10 19:17:20 +00:00
|
|
|
database.RunMigrations(ctx, &database.MigrationConfig{
|
2025-01-08 18:14:15 +00:00
|
|
|
BasePath: path.Join(os.Getenv("PWD"), "../.."),
|
|
|
|
|
})
|
|
|
|
|
})
|
2024-12-24 18:11:25 +00:00
|
|
|
}
|