0815cb35fb
Basic Lint Checks * basic
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
package migrations_test
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path"
|
|
"testing"
|
|
|
|
"queryorchestration/internal/database/migrations"
|
|
"queryorchestration/internal/serviceconfig"
|
|
"queryorchestration/internal/serviceconfig/database"
|
|
"queryorchestration/internal/test"
|
|
|
|
"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 := &serviceconfig.BaseConfig{}
|
|
test.SetCfgProvider(t, cfg)
|
|
cfg.SetBasePath(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 := &serviceconfig.BaseConfig{}
|
|
test.SetCfgProvider(t, cfg)
|
|
cfg.SetBasePath(path.Join(os.Getenv("PWD"), "../../.."))
|
|
cfg.SetDBConfig(&database.DBConfig{
|
|
DBUser: "invalid_user",
|
|
DBSecret: "invalid_pass",
|
|
DBHost: "invalid_host",
|
|
DBPort: 5432,
|
|
DBName: "invalid_name",
|
|
DBNoSSL: true,
|
|
})
|
|
|
|
err := migrations.Run(ctx, cfg)
|
|
assert.Error(t, err)
|
|
}
|