fix(core): restore adapter command behavior

This commit is contained in:
2026-07-11 21:04:53 +02:00
parent a35efa16de
commit 45d57756aa
7 changed files with 141 additions and 29 deletions
+16
View File
@@ -6,6 +6,7 @@ from tht.db.sampling import distinct_values_rest, sample_column_rest
from tht.execute import ExecutionError
from tht.ports import DistinctValues, DwhAdapter
from tht.rest.client import RestError
from tht.adapters.dwh import PostgresDwhAdapter
def postgres_factory():
@@ -145,3 +146,18 @@ def test_postgres_health_only_normalizes_database_errors(monkeypatch):
)
with pytest.raises(ValueError, match="programming bug"):
adapter.health()
def test_non_default_timeout_reaches_query_and_explain(monkeypatch):
adapter = PostgresDwhAdapter(
DatabaseConfig(database="analytics", schema="dw", user="reader", password="secret"),
statement_timeout_ms=12_345,
)
calls = []
monkeypatch.setattr("tht.adapters.dwh.postgres.execute.run_query",
lambda engine, sql, *, limit, timeout_ms: calls.append(("run", timeout_ms)))
monkeypatch.setattr("tht.adapters.dwh.postgres.execute.explain",
lambda engine, sql, *, timeout_ms: calls.append(("explain", timeout_ms)))
adapter.run_query("select 1", limit=2)
adapter.explain("select 1")
assert calls == [("run", 12_345), ("explain", 12_345)]