diff --git a/cmd/auth_test.go b/cmd/auth_test.go index b6adb09d6..4f6d18ca0 100644 --- a/cmd/auth_test.go +++ b/cmd/auth_test.go @@ -23,7 +23,7 @@ func Test_persistentPostRun(t *testing.T) { ctx := context.Background() - adminDBConnectionPool := prepareAdminDBConnectionPool(t, ctx, dbt, true) + adminDBConnectionPool := prepareAdminDBConnectionPool(t, ctx, dbt.DSN) defer adminDBConnectionPool.Close() tenant.PrepareDBForTenant(t, dbt, tenantName) diff --git a/cmd/db_test.go b/cmd/db_test.go index d738e5640..1b8546b3f 100644 --- a/cmd/db_test.go +++ b/cmd/db_test.go @@ -9,7 +9,6 @@ import ( migrate "github.com/rubenv/sql-migrate" "github.com/stellar/go/keypair" "github.com/stellar/go/network" - supportDBTest "github.com/stellar/go/support/db/dbtest" "github.com/stellar/go/support/log" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -24,20 +23,18 @@ import ( "github.com/stellar/stellar-disbursement-platform-backend/stellar-multitenant/pkg/tenant" ) -func prepareAdminDBConnectionPool(t *testing.T, ctx context.Context, dbt *supportDBTest.DB, withMigrations bool) db.DBConnectionPool { +func prepareAdminDBConnectionPool(t *testing.T, ctx context.Context, dbDSN string) db.DBConnectionPool { t.Helper() - adminDatabaseDNS, err := router.GetDNSForAdmin(dbt.DSN) + adminDatabaseDNS, err := router.GetDNSForAdmin(dbDSN) require.NoError(t, err) - if withMigrations { - var manager *cmdDB.SchemaMigrationManager - manager, err = cmdDB.NewSchemaMigrationManager(migrations.AdminMigrationRouter, router.AdminSchemaName, adminDatabaseDNS) - require.NoError(t, err) - defer manager.Close() - err = manager.OrchestrateSchemaMigrations(ctx, migrate.Up, 0) - require.NoError(t, err) - } + var manager *cmdDB.SchemaMigrationManager + manager, err = cmdDB.NewSchemaMigrationManager(migrations.AdminMigrationRouter, router.AdminSchemaName, adminDatabaseDNS) + require.NoError(t, err) + defer manager.Close() + err = manager.OrchestrateSchemaMigrations(ctx, migrate.Up, 0) + require.NoError(t, err) adminDBConnectionPool, err := db.OpenDBConnectionPool(adminDatabaseDNS) require.NoError(t, err) @@ -143,7 +140,7 @@ func Test_DatabaseCommand_db_sdp_migrate(t *testing.T) { ctx := context.Background() - adminDBConnectionPool := prepareAdminDBConnectionPool(t, ctx, dbt, true) + adminDBConnectionPool := prepareAdminDBConnectionPool(t, ctx, dbt.DSN) defer adminDBConnectionPool.Close() m := tenant.NewManager(tenant.WithDatabase(adminDBConnectionPool)) @@ -454,7 +451,7 @@ func Test_DatabaseCommand_db_setup_for_network(t *testing.T) { ctx := context.Background() - adminDBConnectionPool := prepareAdminDBConnectionPool(t, ctx, dbt, true) + adminDBConnectionPool := prepareAdminDBConnectionPool(t, ctx, dbt.DSN) defer adminDBConnectionPool.Close() m := tenant.NewManager(tenant.WithDatabase(adminDBConnectionPool)) diff --git a/stellar-auth/pkg/cli/add_user_test.go b/stellar-auth/pkg/cli/add_user_test.go index c2e885810..27eba1435 100644 --- a/stellar-auth/pkg/cli/add_user_test.go +++ b/stellar-auth/pkg/cli/add_user_test.go @@ -9,7 +9,6 @@ import ( "github.com/lib/pq" migrate "github.com/rubenv/sql-migrate" "github.com/spf13/cobra" - supportDBTest "github.com/stellar/go/support/db/dbtest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -30,20 +29,17 @@ func (m *PasswordPromptMock) Run() (string, error) { var _ PasswordPromptInterface = (*PasswordPromptMock)(nil) -func prepareAdminDBConnectionPool(t *testing.T, ctx context.Context, dbt *supportDBTest.DB, withMigrations bool) db.DBConnectionPool { +func prepareAdminDBConnectionPool(t *testing.T, ctx context.Context, dbDSN string) db.DBConnectionPool { t.Helper() - adminDatabaseDNS, err := router.GetDNSForAdmin(dbt.DSN) + adminDatabaseDNS, err := router.GetDNSForAdmin(dbDSN) require.NoError(t, err) - if withMigrations { - var manager *cmdDB.SchemaMigrationManager - manager, err = cmdDB.NewSchemaMigrationManager(migrations.AdminMigrationRouter, router.AdminSchemaName, adminDatabaseDNS) - require.NoError(t, err) - defer manager.Close() - err = manager.OrchestrateSchemaMigrations(ctx, migrate.Up, 0) - require.NoError(t, err) - } + manager, err := cmdDB.NewSchemaMigrationManager(migrations.AdminMigrationRouter, router.AdminSchemaName, adminDatabaseDNS) + require.NoError(t, err) + defer manager.Close() + err = manager.OrchestrateSchemaMigrations(ctx, migrate.Up, 0) + require.NoError(t, err) adminDBConnectionPool, err := db.OpenDBConnectionPool(adminDatabaseDNS) require.NoError(t, err) @@ -58,7 +54,7 @@ func Test_authAddUserCommand(t *testing.T) { ctx := context.Background() - adminDBConnectionPool := prepareAdminDBConnectionPool(t, ctx, dbt, true) + adminDBConnectionPool := prepareAdminDBConnectionPool(t, ctx, dbt.DSN) defer adminDBConnectionPool.Close() tDSN := tenant.PrepareDBForTenant(t, dbt, tenantName) @@ -225,7 +221,7 @@ func Test_execAddUserFunc(t *testing.T) { ctx := context.Background() - adminDBConnectionPool := prepareAdminDBConnectionPool(t, ctx, dbt, true) + adminDBConnectionPool := prepareAdminDBConnectionPool(t, ctx, dbt.DSN) defer adminDBConnectionPool.Close() tDSN := tenant.PrepareDBForTenant(t, dbt, tenantName)