fix 8 tests failing in Gitea Actions CI environment
Some checks failed
Deploy / build (push) Failing after 9s
Deploy / scan (push) Has been skipped
Deploy / report-vulns (push) Has been skipped
CI / lint-test (push) Failing after 1m24s

- cli tests: strip ANSI escape codes from Rich/typer help output
  before asserting keywords (Rich outputs ANSI in no-TTY mode)
- conf/test_connect: skip DuckDB tests when data/aco.duckdb is
  absent (3GB file not present in CI checkout)
- docs/test_docs_build: resolve paths relative to repo root
  (CI may run from a different working directory)
This commit is contained in:
kert
2026-03-23 21:49:07 -04:00
parent c1e2ac6eaa
commit cda66f8f21
3 changed files with 28 additions and 12 deletions

View File

@@ -2,12 +2,21 @@
from __future__ import annotations
import re
from typer.testing import CliRunner
from cli import app
runner = CliRunner()
_ANSI_RE = re.compile(r"\x1b\[[0-9;]*m")
def _plain(text: str) -> str:
"""Strip ANSI escape codes for assertion matching."""
return _ANSI_RE.sub("", text)
class TestTopLevel:
def test_help(self) -> None:
@@ -69,7 +78,7 @@ class TestBib:
def test_bib_sync_help(self) -> None:
result = runner.invoke(app, ["bib", "sync", "--help"])
assert result.exit_code == 0
assert "dry-run" in result.output
assert "dry-run" in _plain(result.output)
def test_bib_tag(self) -> None:
result = runner.invoke(app, ["bib", "tag"])
@@ -86,19 +95,21 @@ class TestLake:
def test_lake_deploy_help(self) -> None:
result = runner.invoke(app, ["lake", "deploy", "--help"])
assert result.exit_code == 0
assert "catalog-type" in result.output
assert "dry-run" in result.output
out = _plain(result.output)
assert "catalog-type" in out
assert "dry-run" in out
def test_lake_load_help(self) -> None:
result = runner.invoke(app, ["lake", "load", "--help"])
assert result.exit_code == 0
assert "catalog-type" in result.output
assert "mode" in result.output
out = _plain(result.output)
assert "catalog-type" in out
assert "mode" in out
def test_lake_validate_help(self) -> None:
result = runner.invoke(app, ["lake", "validate", "--help"])
assert result.exit_code == 0
assert "catalog-type" in result.output
assert "catalog-type" in _plain(result.output)
def test_lake_parity_help(self) -> None:
result = runner.invoke(app, ["lake", "parity", "--help"])
@@ -139,7 +150,7 @@ class TestDocs:
def test_docs_build_help(self) -> None:
result = runner.invoke(app, ["docs", "build", "--help"])
assert result.exit_code == 0
assert "skip-generate" in result.output
assert "skip-generate" in _plain(result.output)
def test_docs_serve_help(self) -> None:
result = runner.invoke(app, ["docs", "serve", "--help"])

View File

@@ -8,10 +8,13 @@ from unittest.mock import MagicMock, patch
import pytest
from conf import connect
from conf import connect, path
_HAS_ACO_DB = path("db.aco").exists()
class TestDuckdb:
@pytest.mark.skipif(not _HAS_ACO_DB, reason="data/aco.duckdb not present")
def test_returns_connection(self):
con = connect.duckdb()
assert con is not None
@@ -19,6 +22,7 @@ class TestDuckdb:
assert result[0] == 1
con.close()
@pytest.mark.skipif(not _HAS_ACO_DB, reason="data/aco.duckdb not present")
def test_read_only_default(self):
con = connect.duckdb()
with pytest.raises(Exception, match="read-only"):

View File

@@ -8,10 +8,11 @@ import subprocess
import sys
from pathlib import Path
BIB_DB = Path("data/bib.sqlite")
EXPORT_SCRIPT = Path("docs/scripts/export_library.py")
LIBRARY_JSON = Path("docs/static/library.json")
DOCS_DIR = Path("docs/docs")
_ROOT = Path(__file__).resolve().parents[2]
BIB_DB = _ROOT / "data/bib.sqlite"
EXPORT_SCRIPT = _ROOT / "docs/scripts/export_library.py"
LIBRARY_JSON = _ROOT / "docs/static/library.json"
DOCS_DIR = _ROOT / "docs/docs"
INTRO_MD = DOCS_DIR / "intro.md"