sorentwo/oban

Starting postgres and sqlite correctly for development

Closed this issue · 2 comments

I'm trying to run mix test.setup but I'm not sure how to configure postgres to work correctly with the test suite.

If I have a postgres db running (just the default docker container) I receive this error

➜  oban git:(main) ✗ mix test.setup
Compiling 60 files (.ex)
Generated oban app
** (Mix) The database for Oban.Test.Repo couldn't be created: killed

Any tips on how to setup postgres for local dev/testing?

It looks like you have some permission issues. The default setup doesn’t specify a username or password, but you can set a DATABASE_URL with the connection parameters you need.

Here is how it’s done in CI: https://github.com/sorentwo/oban/blob/b092e278c1091319fa48d6f9d9b445ffff57edb5/.github/workflows/ci.yml#L91C35-L91C35

Thank you @sorentwo

===

For future reference and anyone running with their DB in Docker.

Start the docker container with:

docker run --name oban -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust -e PGDATA=/var/lib/postgresql/data/pgdata postgres

You must set POSTGRES_HOST_AUTH_METHOD=trust because otherwise the database expects some password, which the tests don't specify.

Run the tests with the DATABASE_URL parameter, because otherwise it will just fail with your hostname.

DATABASE_URL=postgresql://postgres:postgres@localhost:5432/oban_test mix test.setup

The database url should be set on all invocations of mix.