Skip to content

Fix psqlrc test issue#437

Open
mddelk wants to merge 1 commit into
hanami:mainfrom
mddelk:fix-psql-test-issue
Open

Fix psqlrc test issue#437
mddelk wants to merge 1 commit into
hanami:mainfrom
mddelk:fix-psql-test-issue

Conversation

@mddelk

@mddelk mddelk commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Add some postgres test support cleanup.

  1. Pass -X when calling psql, to avoid loading user configuration.

We're using psql here to list databases, so we need clean output to parse.

This lets us avoid issues when .psqlrc files are present that result in additional stdout, such as:

\pset null '(null)'
  1. Pass exception: true when running postgres system commands.

This makes errors here more obvious, e.g:

Failures:

  1) Hanami::CLI::Commands::App::DB::Create single db in app postgres creates the database
     Failure/Error: system(cmd_env, "dropdb --force #{database}", exception: true)

     RuntimeError:
       Command failed with exit 1: dropdb --force Null display is "(null)".
     # ./spec/support/postgres.rb:25:in 'Kernel#system'
     # ./spec/support/postgres.rb:25:in 'block (3 levels) in <top (required)>'
     # ./spec/support/postgres.rb:24:in 'Array#each'
     # ./spec/support/postgres.rb:24:in 'block (2 levels) in <top (required)>'

Add some postgres test support cleanup.

1. Pass `-X` when calling `psql`, to avoid loading user configuration.

We're using `psql` here to list databases, so we need clean output to parse.

This lets us avoid  issues when `.psqlrc` files are present that result in additional stdout, such as:

```
\pset null '(null)'
```

2. Pass `exception: true` when running postgres `system` commands.

This makes errors here more obvious, e.g:

```
Failures:

  1) Hanami::CLI::Commands::App::DB::Create single db in app postgres creates the database
     Failure/Error: system(cmd_env, "dropdb --force #{database}", exception: true)

     RuntimeError:
       Command failed with exit 1: dropdb --force Null display is "(null)".
     # ./spec/support/postgres.rb:25:in 'Kernel#system'
     # ./spec/support/postgres.rb:25:in 'block (3 levels) in <top (required)>'
     # ./spec/support/postgres.rb:24:in 'Array#each'
     # ./spec/support/postgres.rb:24:in 'block (2 levels) in <top (required)>'
```
@mddelk
mddelk marked this pull request as ready for review July 12, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant