7001ca854c
Queuing Changes and Cfg Testing * staarting * staarting * startedpush * note * save * mocking * removederrs * fixtests * cleanuperrs * newenvsetup * preppingtests * queue * mmovetocfgpassunittests * sortoutconfig * passinginteg * deps * fixtests
47 lines
962 B
Go
47 lines
962 B
Go
package migrations_test
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path"
|
|
"queryorchestration/internal/database/migrations"
|
|
"queryorchestration/internal/test"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestRunMigrations(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("Skipping long test in short mode")
|
|
}
|
|
ctx := context.Background()
|
|
|
|
cfg := test.CreateBaseConfig()
|
|
cfg.BasePath = path.Join(os.Getenv("PWD"), "../../..")
|
|
|
|
_, cleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{
|
|
Cfg: cfg,
|
|
})
|
|
defer cleanup()
|
|
|
|
err := migrations.Run(ctx, cfg)
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
func TestRunMigrationsNoDB(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
cfg := test.CreateBaseConfig()
|
|
cfg.BasePath = path.Join(os.Getenv("PWD"), "../../..")
|
|
cfg.DBUser = "invalid_user"
|
|
cfg.DBSecret = "invalid_pass"
|
|
cfg.DBHost = "invalid_host"
|
|
cfg.DBPort = 5432
|
|
cfg.DBName = "invalid_name"
|
|
cfg.DBNoSSL = true
|
|
|
|
err := migrations.Run(ctx, cfg)
|
|
assert.Error(t, err)
|
|
}
|