Skip to content

Fix psqlrc test issue - #437

Merged
timriley merged 3 commits into
hanami:mainfrom
mddelk:fix-psql-test-issue
Jul 29, 2026
Merged

Fix psqlrc test issue#437
timriley merged 3 commits 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
@katafrakt

Copy link
Copy Markdown
Contributor

For reference, as I actually did not know this switch:

  -X, --no-psqlrc          do not read startup file (~/.psqlrc)

This generally looks like a good change to me.

@github-actions

Copy link
Copy Markdown
Contributor

ℹ️ Optional job failed: Ruby jruby

@timriley

Copy link
Copy Markdown
Member

Thanks @mddelk! We're gonna have a hanami-cli patch release soon in your honour :)

@timriley
timriley merged commit fb6e3d2 into hanami:main Jul 29, 2026
11 checks passed
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.

3 participants