mirror of
https://github.com/hanzo-fi/stack.git
synced 2026-10-30 20:34:43 +00:00
34 lines
900 B
Go
34 lines
900 B
Go
package bunmigrate
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/formancehq/stack/libs/go-libs/bun/bunconnect"
|
|
"github.com/formancehq/stack/libs/go-libs/logging"
|
|
"github.com/formancehq/stack/libs/go-libs/pgtesting"
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/uptrace/bun"
|
|
)
|
|
|
|
func TestRunMigrate(t *testing.T) {
|
|
require.NoError(t, pgtesting.CreatePostgresServer())
|
|
t.Cleanup(func() {
|
|
require.NoError(t, pgtesting.DestroyPostgresServer())
|
|
})
|
|
|
|
connectionOptions := &bunconnect.ConnectionOptions{
|
|
DatabaseSourceName: pgtesting.Server().GetDatabaseDSN("testing"),
|
|
}
|
|
executor := func(args []string, db *bun.DB) error {
|
|
return nil
|
|
}
|
|
|
|
err := run(logging.TestingContext(), os.Stdout, []string{}, connectionOptions, executor)
|
|
require.NoError(t, err)
|
|
|
|
// Must be idempotent
|
|
err = run(logging.TestingContext(), os.Stdout, []string{}, connectionOptions, executor)
|
|
require.NoError(t, err)
|
|
}
|