Files
query-orchestration/internal/database/migrations_test.go
T
Jay Brown 174644b63c Merged in jb/openapi (pull request #22)
add openapi infra

* add openapi infra

Includes generated stubs and all deps

* generatetolocation

* basesetupoffunctionsandclient

* round1controllertests

* passintegrationtests

* cleanupfromfullsuite

* storedjson

* fixjsonyaml

* fixtests


Approved-by: Michael McGuinness
2025-01-15 19:45:51 +00:00

41 lines
877 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{})
defer cleanup()
database.RunMigrations(ctx, &database.MigrationConfig{
BasePath: path.Join(os.Getenv("PWD"), "../.."),
})
}
func TestRunMigrationsNoDB(t *testing.T) {
ctx := context.Background()
t.Setenv("DB_USER", "invalid_user")
t.Setenv("DB_PASS", "invalid_pass")
t.Setenv("DB_HOST", "invalid_host")
t.Setenv("DB_PORT", "5432")
t.Setenv("DB_NAME", "invalid_name")
t.Setenv("DB_NOSSL", "1")
assert.Panics(t, func() {
database.RunMigrations(ctx, &database.MigrationConfig{
BasePath: path.Join(os.Getenv("PWD"), "../.."),
})
})
}