fix: suppress legacy warnings in machine JSON paths

This commit is contained in:
2026-08-11 05:50:06 +02:00
parent 554de4ff2f
commit d5f752dd7b
3 changed files with 62 additions and 4 deletions
+42
View File
@@ -61,6 +61,18 @@ embeddings:
return cfg
def _legacy_qdrant_runtime_config(tmp_path: Path) -> Path:
cfg = _qdrant_runtime_config(tmp_path)
text = cfg.read_text()
text = text.replace(
"dwh:\n type: postgres_direct\n connection: {database: analytics, schema: mart, user: reader, password: secret}\n",
"database: {database: analytics, schema: mart, user: reader, password: secret}\n",
)
text = text.replace("roots:\n", "paths:\n")
cfg.write_text(text)
return cfg
def _write_schema_artifacts(tmp_path: Path) -> None:
(tmp_path / "artifacts" / "mschema").mkdir(parents=True, exist_ok=True)
(tmp_path / "artifacts" / "mschema" / "physical.yaml").write_text(
@@ -252,3 +264,33 @@ def test_vector_index_schema_human_missing_config_has_original_error(tmp_path):
assert response.exit_code == 1
assert response.output
assert "ERRORE:" in response.output
def test_vector_index_schema_json_legacy_config_has_no_stderr_on_success(monkeypatch, tmp_path):
cfg = _legacy_qdrant_runtime_config(tmp_path)
_write_schema_artifacts(tmp_path)
store = _FakeVectorStore()
monkeypatch.setattr("tht.adapters.factory.build_vector_store", lambda cfg, require_write: store)
monkeypatch.setattr("tht.cli.vector_cmd.make_embedder", lambda _: _FakeEmbedder())
response = CliRunner().invoke(app, ["vector", "index-schema", "--json", "-c", str(cfg)])
assert response.exit_code == 0, response.output
assert response.stderr == ""
assert response.stdout.count("\n") == 1
assert json.loads(response.stdout)["status"] == "succeeded"
def test_vector_index_schema_json_legacy_config_has_no_stderr_on_failure(tmp_path):
cfg = _legacy_qdrant_runtime_config(tmp_path)
_write_schema_artifacts(tmp_path)
(tmp_path / "artifacts" / "mschema" / "physical.yaml").unlink()
response = CliRunner().invoke(app, ["vector", "index-schema", "--json", "-c", str(cfg)])
assert response.exit_code == 1
assert response.stderr == ""
assert response.stdout.count("\n") == 1
assert json.loads(response.stdout) == {
"status": "failed", "code": "physical_schema_missing"
}