Postgres CI testing — rewrite test fixtures, add Woodpecker service container #16

Closed
opened 2026-03-09 22:50:55 +00:00 by forgejo_admin · 0 comments

Lineage

plan-2026-03-08-tryout-prep → Phase 1b

Repo

forgejo_admin/basketball-api

User Story

As a developer
I want CI to run tests against real Postgres instead of SQLite
So that tests catch real bugs and the pipeline passes, unblocking deployment

Context

Tests currently use SQLite via module-level engine/session overrides. test_register.py and test_coach.py both override get_db at different scopes and stomp each other — 6 tests fail. SQLite also hides real bugs (e.g. date_of_birth type mismatch). The registration form and coach onboarding are merged but nothing deploys until CI passes.

Ruff formatting is already fixed (PR #15). This issue is only about Postgres CI testing.

Note: Woodpecker CI logs are currently broken platform-wide (upstream bug). You won't see logs in the UI. To verify locally, run pytest against a real Postgres instance.

File Targets

Files the agent should modify:

  • .woodpecker.yaml — add Postgres service container, set DATABASE_URL env var in test step
  • tests/conftest.py — shared Postgres test fixtures (engine, session, TestClient)
  • tests/test_register.py — remove module-level SQLite setup, use conftest fixtures
  • tests/test_coach.py — remove module-level SQLite setup, use conftest fixtures
  • tests/test_models.py — use conftest fixtures if applicable

Files the agent should NOT touch:

  • src/ application code — no app changes, test infrastructure only
  • Migration files — no schema changes

Acceptance Criteria

  • .woodpecker.yaml has a Postgres service container (e.g. postgres:16-alpine)
  • DATABASE_URL env var set in test step pointing to Woodpecker Postgres service
  • tests/conftest.py provides shared fixtures: engine, session, TestClient with DB override
  • No module-level get_db overrides in individual test files
  • All existing tests pass against Postgres
  • ruff format --check . still passes
  • ruff check . still passes

Test Expectations

  • All tests in test_register.py pass against Postgres
  • All tests in test_coach.py pass against Postgres (mocked Stripe)
  • All tests in test_models.py pass
  • No SQLite references remain in test files
  • Run command: DATABASE_URL=postgresql://test:test@localhost:5432/test pytest tests/ -v

Constraints

  • Woodpecker services: block for Postgres sidecar — see Woodpecker docs for K8s backend service syntax
  • Use postgres:16-alpine image for consistency with CNPG production
  • Test DB should be created fresh per test session (create_all / drop_all)
  • Keep mocked Stripe in coach tests — do not add real Stripe dependency

Checklist

  • PR opened
  • Tests pass
  • No unrelated changes
  • plan-2026-03-08-tryout-prep — tryout prep plan
  • basketball-api #14 — ruff format fix (CLOSED, PR #15)
### Lineage `plan-2026-03-08-tryout-prep` → Phase 1b ### Repo `forgejo_admin/basketball-api` ### User Story As a developer I want CI to run tests against real Postgres instead of SQLite So that tests catch real bugs and the pipeline passes, unblocking deployment ### Context Tests currently use SQLite via module-level engine/session overrides. `test_register.py` and `test_coach.py` both override `get_db` at different scopes and stomp each other — 6 tests fail. SQLite also hides real bugs (e.g. date_of_birth type mismatch). The registration form and coach onboarding are merged but nothing deploys until CI passes. Ruff formatting is already fixed (PR #15). This issue is only about Postgres CI testing. Note: Woodpecker CI logs are currently broken platform-wide (upstream bug). You won't see logs in the UI. To verify locally, run `pytest` against a real Postgres instance. ### File Targets Files the agent should modify: - `.woodpecker.yaml` — add Postgres service container, set DATABASE_URL env var in test step - `tests/conftest.py` — shared Postgres test fixtures (engine, session, TestClient) - `tests/test_register.py` — remove module-level SQLite setup, use conftest fixtures - `tests/test_coach.py` — remove module-level SQLite setup, use conftest fixtures - `tests/test_models.py` — use conftest fixtures if applicable Files the agent should NOT touch: - `src/` application code — no app changes, test infrastructure only - Migration files — no schema changes ### Acceptance Criteria - [ ] `.woodpecker.yaml` has a Postgres service container (e.g. `postgres:16-alpine`) - [ ] `DATABASE_URL` env var set in test step pointing to Woodpecker Postgres service - [ ] `tests/conftest.py` provides shared fixtures: engine, session, TestClient with DB override - [ ] No module-level `get_db` overrides in individual test files - [ ] All existing tests pass against Postgres - [ ] `ruff format --check .` still passes - [ ] `ruff check .` still passes ### Test Expectations - [ ] All tests in `test_register.py` pass against Postgres - [ ] All tests in `test_coach.py` pass against Postgres (mocked Stripe) - [ ] All tests in `test_models.py` pass - [ ] No SQLite references remain in test files - Run command: `DATABASE_URL=postgresql://test:test@localhost:5432/test pytest tests/ -v` ### Constraints - Woodpecker `services:` block for Postgres sidecar — see Woodpecker docs for K8s backend service syntax - Use `postgres:16-alpine` image for consistency with CNPG production - Test DB should be created fresh per test session (create_all / drop_all) - Keep mocked Stripe in coach tests — do not add real Stripe dependency ### Checklist - [ ] PR opened - [ ] Tests pass - [ ] No unrelated changes ### Related - `plan-2026-03-08-tryout-prep` — tryout prep plan - basketball-api #14 — ruff format fix (CLOSED, PR #15)
forgejo_admin 2026-03-09 23:04:58 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo_admin/basketball-api#16
No description provided.