174644b63c
add openapi infra * add openapi infra Includes generated stubs and all deps * generatetolocation * basesetupoffunctionsandclient * round1controllertests * passintegrationtests * cleanupfromfullsuite * storedjson * fixjsonyaml * fixtests Approved-by: Michael McGuinness
41 lines
877 B
Go
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"), "../.."),
|
|
})
|
|
})
|
|
}
|