diff --git a/.gitignore b/.gitignore index 6c5114b..2b9985d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ alembic.ini .idea .pytest_cache .mypy_cache -.coverage +*.coverage *.pyc *.log test.db @@ -14,3 +14,4 @@ site profile.py *.db *.db-journal +*coverage.xml \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0995692 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +PIPENV_RUN := pipenv run +PG_DOCKERFILE_NAME := fastapi-users-test-mongo + +test_all: test_pg test_mysql test_sqlite + +test_pg: export DATABASE_URL=postgresql://username:password@localhost:5432/testsuite +test_pg: + docker-compose -f scripts/docker-compose.yml up -d postgres + bash scripts/test.sh -svv + docker-compose stop postgres + +test_mysql: export DATABASE_URL=mysql://username:password@127.0.0.1:3306/testsuite +test_mysql: + docker-compose -f "scripts/docker-compose.yml" up -d mysql + bash scripts/test.sh -svv + docker-compose stop mysql + +test_sqlite: + bash scripts/test.sh -svv \ No newline at end of file diff --git a/scripts/docker-compose.yml b/scripts/docker-compose.yml new file mode 100644 index 0000000..c6ad36e --- /dev/null +++ b/scripts/docker-compose.yml @@ -0,0 +1,20 @@ +version: '2.1' +services: + postgres: + image: postgres:10.8 + environment: + POSTGRES_USER: username + POSTGRES_PASSWORD: password + POSTGRES_DB: testsuite + ports: + - 5432:5432 + + mysql: + image: mysql:5.7 + environment: + MYSQL_USER: username + MYSQL_PASSWORD: password + MYSQL_ROOT_PASSWORD: password + MYSQL_DATABASE: testsuite + ports: + - 3306:3306 \ No newline at end of file diff --git a/tests/settings.py b/tests/settings.py index 6d89f4e..fededf3 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -6,3 +6,4 @@ DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:///test.db") database_url = databases.DatabaseURL(DATABASE_URL) if database_url.scheme == "postgresql+aiopg": # pragma no cover DATABASE_URL = str(database_url.replace(driver=None)) +print('USED DB:', DATABASE_URL)