fix(core): restore adapter command behavior
This commit is contained in:
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user