mirror of https://github.com/stijndcl/didier
Add test container
parent
ca9dd84ab5
commit
5f2e26f154
|
@ -27,16 +27,13 @@ jobs:
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:14
|
image: postgres:14
|
||||||
env:
|
|
||||||
POSTGRES_DB: didier_action
|
|
||||||
POSTGRES_PASSWORD: postgres
|
|
||||||
options: >-
|
options: >-
|
||||||
--health-cmd pg_isready
|
--health-cmd pg_isready
|
||||||
--health-interval 10s
|
--health-interval 10s
|
||||||
--health-timeout 5s
|
--health-timeout 5s
|
||||||
--health-retries 5
|
--health-retries 5
|
||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5433:5432
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
|
@ -54,10 +51,6 @@ jobs:
|
||||||
run: pip3 install -r requirements.txt -r requirements-dev.txt
|
run: pip3 install -r requirements.txt -r requirements-dev.txt
|
||||||
- name: Run Pytest
|
- name: Run Pytest
|
||||||
run: pytest tests
|
run: pytest tests
|
||||||
env:
|
|
||||||
DB_TEST_SQLITE: false
|
|
||||||
DB_NAME: didier_action
|
|
||||||
DB_PASSWORD: postgres
|
|
||||||
linting:
|
linting:
|
||||||
needs: [dependencies]
|
needs: [dependencies]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
@ -6,16 +6,6 @@ from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
import settings
|
import settings
|
||||||
|
|
||||||
# Run local tests against SQLite instead of Postgres
|
|
||||||
if settings.TESTING and settings.DB_TEST_SQLITE:
|
|
||||||
engine = create_async_engine(
|
|
||||||
URL.create(
|
|
||||||
drivername="sqlite+aiosqlite",
|
|
||||||
database="tests.db",
|
|
||||||
),
|
|
||||||
connect_args={"check_same_thread": False},
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
encoded_password = quote_plus(settings.DB_PASSWORD)
|
encoded_password = quote_plus(settings.DB_PASSWORD)
|
||||||
engine = create_async_engine(
|
engine = create_async_engine(
|
||||||
URL.create(
|
URL.create(
|
||||||
|
|
|
@ -12,5 +12,15 @@ services:
|
||||||
- "${DB_PORT:-5432}:${DB_PORT:-5432}"
|
- "${DB_PORT:-5432}:${DB_PORT:-5432}"
|
||||||
volumes:
|
volumes:
|
||||||
- db:/var/lib/postgresql/data
|
- db:/var/lib/postgresql/data
|
||||||
|
db-pytest:
|
||||||
|
image: postgres:14
|
||||||
|
container_name: didier-pytest
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
- POSTGRES_DB=didier_pytest
|
||||||
|
- POSTGRES_USER=pytest
|
||||||
|
- POSTGRES_PASSWORD=pytest
|
||||||
|
ports:
|
||||||
|
- "5433:5432"
|
||||||
volumes:
|
volumes:
|
||||||
db:
|
db:
|
||||||
|
|
|
@ -24,9 +24,10 @@ good-names = ["i", "dt"]
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
asyncio_mode = "auto"
|
asyncio_mode = "auto"
|
||||||
env = [
|
env = [
|
||||||
"TESTING = true",
|
"DB_NAME = didier_pytest",
|
||||||
"DB_NAME = didier_action",
|
"DB_USERNAME = pytest",
|
||||||
"DB_USERNAME = postgres",
|
"DB_PASSWORD = pytest",
|
||||||
"DB_HOST = localhost",
|
"DB_HOST = localhost",
|
||||||
|
"DB_PORT = 5433",
|
||||||
"DISC_TOKEN = token"
|
"DISC_TOKEN = token"
|
||||||
]
|
]
|
||||||
|
|
|
@ -9,7 +9,6 @@ env.read_env()
|
||||||
"""General config"""
|
"""General config"""
|
||||||
SANDBOX: bool = env.bool("SANDBOX", True)
|
SANDBOX: bool = env.bool("SANDBOX", True)
|
||||||
LOGFILE: str = env.str("LOGFILE", "didier.log")
|
LOGFILE: str = env.str("LOGFILE", "didier.log")
|
||||||
TESTING: bool = env.bool("TESTING", False)
|
|
||||||
|
|
||||||
"""Database"""
|
"""Database"""
|
||||||
DB_NAME: str = env.str("DB_NAME", "didier")
|
DB_NAME: str = env.str("DB_NAME", "didier")
|
||||||
|
@ -17,7 +16,6 @@ DB_USERNAME: str = env.str("DB_USERNAME", "postgres")
|
||||||
DB_PASSWORD: str = env.str("DB_PASSWORD", "")
|
DB_PASSWORD: str = env.str("DB_PASSWORD", "")
|
||||||
DB_HOST: str = env.str("DB_HOST", "localhost")
|
DB_HOST: str = env.str("DB_HOST", "localhost")
|
||||||
DB_PORT: int = env.int("DB_PORT", "5432")
|
DB_PORT: int = env.int("DB_PORT", "5432")
|
||||||
DB_TEST_SQLITE: bool = env.bool("DB_TEST_SQLITE", True)
|
|
||||||
|
|
||||||
"""Discord"""
|
"""Discord"""
|
||||||
DISCORD_TOKEN: str = env.str("DISC_TOKEN")
|
DISCORD_TOKEN: str = env.str("DISC_TOKEN")
|
||||||
|
|
Loading…
Reference in New Issue