81e7223560
Text Extraction * bases * go * splitting * structure * movetoasync * movetoasync * settinguptrigger * reorder * storevent * standardisepollingvalidation * unittests * fixlint * fixlint * awscfg * generatesample * followthrough * tests * clena * store * externalidcleanup * clientid * local * baseunittests * putobjecttests * tests
46 lines
1009 B
Go
46 lines
1009 B
Go
package database_test
|
|
|
|
import (
|
|
"context"
|
|
"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 := context.Background()
|
|
|
|
cfg := &serviceconfig.BaseConfig{}
|
|
test.SetCfgProvider(t, cfg)
|
|
|
|
_, cleanup := test.CreateDB(t, ctx, cfg, &test.CreateDatabaseConfig{})
|
|
defer cleanup()
|
|
|
|
err := migrations.RunMigrations(ctx, cfg)
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
func TestRunMigrationsNoDB(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
cfg := &serviceconfig.BaseConfig{}
|
|
test.SetCfgProvider(t, cfg)
|
|
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(ctx, cfg)
|
|
assert.Error(t, err)
|
|
}
|