Test the revision lock of the CLI stages
The `@db_revision` decorator no longer skips its check under `TESTING`. The tests replace `current_db_revision()` with the revision they need.
This commit is contained in:
parent
eb059c1ea5
commit
2add322a25
1 changed files with 56 additions and 14 deletions
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import collections.abc as cabc
|
||||
import functools
|
||||
import os
|
||||
import sys
|
||||
import typing as t
|
||||
|
||||
|
|
@ -39,19 +38,17 @@ def db_revision(rev: str) -> cabc.Callable[..., cabc.Callable[..., t.Any]]:
|
|||
@functools.wraps(func)
|
||||
def ensure(*args: t.Any, **kwargs: t.Any) -> t.Any:
|
||||
"""Do not execute the `func` if the revision does not match."""
|
||||
# Skip in tests as the database then either has no or the latest revision
|
||||
if not os.getenv("TESTING"): # pragma: no cover
|
||||
current = current_db_revision()
|
||||
current = current_db_revision()
|
||||
|
||||
if current != rev:
|
||||
click.echo(
|
||||
click.style(
|
||||
f"Database is at revision {current},"
|
||||
f" but this stage requires {rev}",
|
||||
fg="red",
|
||||
),
|
||||
)
|
||||
sys.exit(1)
|
||||
if current != rev:
|
||||
click.echo(
|
||||
click.style(
|
||||
f"Database is at revision {current},"
|
||||
f" but this stage requires {rev}",
|
||||
fg="red",
|
||||
),
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
return func(*args, **kwargs)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue