fee71e7740
Feature/postprocessing * tests * passtest * fixshorttests * mosttests * improvingbasedockerfile * testspeeds * testing * host * canparallel * clean * passfullsuite * singlepagemax * test * findfeatures * findstables * tbls * tablestoo * tablestoo * lateraltests * tableloc * cleanup * inlinetable * childids * cleanup * tests
40 lines
922 B
Go
40 lines
922 B
Go
package database_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
migrations "queryorchestration/internal/database"
|
|
"queryorchestration/internal/serviceconfig"
|
|
"queryorchestration/internal/test"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestRunMigrations(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("Skipping long test in short mode")
|
|
}
|
|
ctx := t.Context()
|
|
cfg := &serviceconfig.BaseConfig{}
|
|
|
|
net := test.DepNetwork.Get(t, ctx)
|
|
_ = test.CreateDB(t, ctx, cfg, net, &test.CreateDatabaseConfig{})
|
|
|
|
err := migrations.RunMigrations(ctx, cfg)
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
func TestRunMigrationsNoDB(t *testing.T) {
|
|
cfg := &serviceconfig.BaseConfig{}
|
|
cfg.SetDBUser("invalid_user")
|
|
cfg.SetDBSecret("invalid_pass")
|
|
cfg.SetDBHost("invalid_host")
|
|
cfg.SetDBPort(5432)
|
|
cfg.SetDBName("invalid_name")
|
|
cfg.SetDBNoSSL(true)
|
|
|
|
err := migrations.RunMigrations(t.Context(), cfg)
|
|
assert.Error(t, err)
|
|
}
|