Skip to content

Commit

Permalink
chore: fix tests mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
avallete committed Sep 24, 2024
1 parent bb28463 commit 5e94687
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/db/reset/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ func recreateDatabase(ctx context.Context, options ...func(*pgx.ConnConfig)) err
sql := migration.MigrationFile{
Statements: []string{
"DROP DATABASE IF EXISTS postgres WITH (FORCE)",
"DROP DATABASE IF EXISTS _supabase WITH (FORCE)",
"CREATE DATABASE postgres WITH OWNER postgres",
"DROP DATABASE IF EXISTS _supabase WITH (FORCE)",
"CREATE DATABASE _supabase WITH OWNER postgres",
},
}
Expand Down
11 changes: 9 additions & 2 deletions internal/db/reset/reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ func TestRecreateDatabase(t *testing.T) {
Query("DROP DATABASE IF EXISTS postgres WITH (FORCE)").
Reply("DROP DATABASE").
Query("CREATE DATABASE postgres WITH OWNER postgres").
Reply("CREATE DATABASE").
Query("DROP DATABASE IF EXISTS _supabase WITH (FORCE)").
Reply("DROP DATABASE").
Query("CREATE DATABASE _supabase WITH OWNER postgres").
Reply("CREATE DATABASE")
// Run test
assert.NoError(t, recreateDatabase(context.Background(), conn.Intercept))
Expand Down Expand Up @@ -194,8 +198,11 @@ func TestRecreateDatabase(t *testing.T) {
Reply("DO").
Query("DROP DATABASE IF EXISTS postgres WITH (FORCE)").
ReplyError(pgerrcode.ObjectInUse, `database "postgres" is used by an active logical replication slot`).
Query("CREATE DATABASE postgres WITH OWNER postgres")
// Run test
Query("CREATE DATABASE postgres WITH OWNER postgres").
Query("DROP DATABASE IF EXISTS _supabase WITH (FORCE)").
Reply("DROP DATABASE").
Query("CREATE DATABASE _supabase WITH OWNER postgres").
Reply("CREATE DATABASE")
err := recreateDatabase(context.Background(), conn.Intercept)
// Check error
assert.ErrorContains(t, err, `ERROR: database "postgres" is used by an active logical replication slot (SQLSTATE 55006)`)
Expand Down

0 comments on commit 5e94687

Please sign in to comment.