migra
migra copied to clipboard
How to run tests?
The question/request: instructions for running the tests from a cold start. Better yet, a script to set up a database server for running the tests.
Here's the story that led to me filing this issue.
To check my development environment, I wanted to run the unit tests. make test
was a familiar way to do so. First, that failed since I didn't have my virtualenv activated. Then, the tests failed since I didn't have postgres running. That wasn't unexpected I fired up a server using docker run -p 5432:5432 -d postgres:12-alpine
. That command failed since docker.io/library/postgres expects explicit authentication configuration. I set POSTGRES_HOST_AUTH_METHOD=trust
, and found out the tests expect the postgres server to have a user with the same username as the current user running the tests.
I couldn't find docs on running the tests, so I copied the ./.circleci/config.yml
and ran
docker run -d \
-e POSTGRES_HOST_AUTH_METHOD=trust \
-e POSTGRES_USER=$USER \
-e POSTGRES_DATABASE=$USER \
-p 5432:5432 \
postgres:13
Now tests/test_migra.py::test_singleschema
is failing with psycopg2.errors.UndefinedObject: role "postgres" does not exist
, and I'm still lost. Hence the issue.
Hello, thanks for filing this and apols for the slow reply.
The tests could definitely be a lot more configurable/easier - with my own configuration, I just have postgres running locally (and mariadb for schemainspect).
With the user/auth, the tests are expecting to have passwordless access (if you can't do psql $CONNECTIONSTRING
and get access without a password prompt, the tests won't work). Try setting the user/database to postgres
perhaps?