Cover the Postgres queue construction paths in CI
This commit is contained in:
parent
73e8ac2dd6
commit
e2e0a8dc1b
2 changed files with 31 additions and 2 deletions
|
|
@ -135,6 +135,10 @@ filterwarnings = ["error", "ignore::UserWarning", "ignore::DeprecationWarning"]
|
|||
|
||||
[tool.coverage.run]
|
||||
source = ["haiku_rag_slim"]
|
||||
# aiosqlite runs sqlite (and the queue's PRAGMA connect listener) off the main
|
||||
# flow via a greenlet + worker thread; track both so that code isn't reported
|
||||
# as uncovered.
|
||||
concurrency = ["greenlet", "thread"]
|
||||
omit = [
|
||||
"haiku_rag_slim/haiku/rag/chat/*",
|
||||
"haiku_rag_slim/haiku/rag/inspector/*",
|
||||
|
|
|
|||
|
|
@ -5,9 +5,14 @@ import pytest
|
|||
import sqlalchemy as sa
|
||||
|
||||
from haiku.rag.config import QueueConfig
|
||||
from haiku.rag.ingester.queue.migrations import apply_migrations, open_queue
|
||||
from haiku.rag.ingester.queue.db import jobs as jobs_table
|
||||
from haiku.rag.ingester.queue.migrations import (
|
||||
apply_migrations,
|
||||
make_engine,
|
||||
open_queue,
|
||||
)
|
||||
from haiku.rag.ingester.queue.models import JobOp, JobStatus, SyncRow
|
||||
from haiku.rag.ingester.queue.repository import JobRepo
|
||||
from haiku.rag.ingester.queue.repository import JobRepo, _insert
|
||||
|
||||
# --- migrations / schema ---
|
||||
|
||||
|
|
@ -44,6 +49,26 @@ async def test_open_queue_creates_file_and_schema(tmp_path):
|
|||
await eng.dispose()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_make_engine_postgres_is_pre_ping():
|
||||
"""The Postgres branch builds a pre-ping engine without connecting."""
|
||||
engine = make_engine(QueueConfig(dburi="postgresql+asyncpg://u:p@localhost/db"))
|
||||
try:
|
||||
assert engine.dialect.name == "postgresql"
|
||||
assert engine.pool._pre_ping is True
|
||||
finally:
|
||||
await engine.dispose()
|
||||
|
||||
|
||||
def test_insert_uses_dialect_specific_construct():
|
||||
"""_insert dispatches to the dialect's INSERT (which exposes on_conflict_*)."""
|
||||
from sqlalchemy.dialects.postgresql import Insert as PostgresInsert
|
||||
from sqlalchemy.dialects.sqlite import Insert as SqliteInsert
|
||||
|
||||
assert isinstance(_insert(jobs_table, "postgresql"), PostgresInsert)
|
||||
assert isinstance(_insert(jobs_table, "sqlite"), SqliteInsert)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_open_queue_handles_path_with_url_chars(tmp_path):
|
||||
"""A `?` (or `#`) is a valid POSIX filename char but has URL meaning.
|
||||
|
|
|
|||
Loading…
Reference in a new issue