feat(sources): admin page to add and remove git sources (TODO.md L4)
This commit is contained in:
@@ -5,12 +5,15 @@ Drives the **real Alembic engine** against the live dev database
|
||||
``test_migration_0004.py`` (information_schema assertions on the state the
|
||||
migration must leave):
|
||||
|
||||
* upgrade to head → ``kb_overview`` exists with exactly the three columns
|
||||
The tests target revision ``0005`` explicitly so later migrations
|
||||
(0006, …) cannot break them.
|
||||
|
||||
* upgrade to 0005 → ``kb_overview`` exists with exactly the three columns
|
||||
the phase locks in (``id INTEGER PK`` default 1, ``content TEXT NOT NULL``
|
||||
default ``''``, ``updated_at TIMESTAMPTZ NOT NULL`` default ``now()``),
|
||||
and a bare insert lands the single-row defaults (id=1, content='');
|
||||
* downgrade to 0004 → the table is gone;
|
||||
* upgrade to head again → it is back (round-trip).
|
||||
* upgrade to 0005 again → it is back (round-trip).
|
||||
|
||||
The ``alembic`` fixture guarantees the DB ends at head even if a test
|
||||
fails or the process is interrupted.
|
||||
@@ -65,14 +68,14 @@ def _version(db: Session) -> str | None:
|
||||
return db.execute(text("SELECT version_num FROM alembic_version")).scalar()
|
||||
|
||||
|
||||
def test_upgrade_to_head_creates_kb_overview(db: Session, alembic: Config) -> None:
|
||||
"""Upgrade to head: the single-row table exists with the locked
|
||||
def test_upgrade_to_0005_creates_kb_overview(db: Session, alembic: Config) -> None:
|
||||
"""Upgrade 0004 → 0005: the single-row table exists with the locked
|
||||
column types, nullability, and server defaults."""
|
||||
command.downgrade(alembic, "0004") # start from the pre-0005 state
|
||||
assert _version(db) == "0004"
|
||||
|
||||
command.upgrade(alembic, "head")
|
||||
assert _version(db) == "0005", "alembic_version must be at 0005 (head)"
|
||||
command.upgrade(alembic, "0005")
|
||||
assert _version(db) == "0005", "alembic_version must be at 0005"
|
||||
|
||||
pk = db.execute(
|
||||
text(
|
||||
@@ -139,9 +142,11 @@ def test_downgrade_to_0004_drops_table(db: Session, alembic: Config) -> None:
|
||||
|
||||
|
||||
def test_upgrade_round_trip_restores_table(db: Session, alembic: Config) -> None:
|
||||
"""Upgrade back to head after the downgrade: table + defaults are back."""
|
||||
command.upgrade(alembic, "head")
|
||||
assert _version(db) == "0005", "round-trip upgrade must land at 0005 (head)"
|
||||
"""Downgrade to 0004, then upgrade back to 0005: table + defaults are
|
||||
back (self-contained — does not rely on a prior test's downgrade)."""
|
||||
command.downgrade(alembic, "0004")
|
||||
command.upgrade(alembic, "0005")
|
||||
assert _version(db) == "0005", "round-trip upgrade must land at 0005"
|
||||
|
||||
id_col = _column(db, "id")
|
||||
assert id_col is not None and id_col[2] == "1", "kb_overview.id must be back with default 1"
|
||||
|
||||
Reference in New Issue
Block a user