eulerto / pgquarrel

pgquarrel compares PostgreSQL database schemas (DDL)
BSD 3-Clause "New" or "Revised" License
389 stars 42 forks source link

test: make PG directories configurable, PGQUARREL path configurable #102

Closed mitchellh closed 1 year ago

mitchellh commented 2 years ago

This doesn't change any default behavior of run-test.sh, so it continues to behave identically, but adds some additional configuration that users can opt-in. This makes it possible for me to run tests.

The run-test.sh can now be run from any directory. It uses some bash (which is already required from the shebang) to detect the current directory and remain equivalent to behavior prior to this change.

This allows for the directory to the PostgreSQL installation to be configurable using the "PGPATH_" environment variable. For example, if running tests using run-test.sh 14 14 and you have PGPATH_14 in your env, it'll use that instead of $HOME/pg14.

This also allows for configuring the path to the pgquarrel binary by setting the PGQUARREL environment variable.

Finally, I changed the unix socket directory to the temp directory so that we don't need permission to /var/run or /run (whatever the default is for your system) since this isn't always there.

Why? On my system (NixOS), my PostgreSQL installations are in other directories from my package manager I'd like to point to. And likewise, I compile pgquarrel using a Nix package so its again at a different directory. Finally, /run isn't writable by normal users on NixOS so for tests I want to move that.

I know these are multiple changes in one PR, please let me know if you disagree with any or want me to break it up, but I felt they were all small and aimed towards the same thing.