Milestone 2’s core deterministic scanner path

This commit is contained in:
2026-04-25 22:32:05 +02:00
parent 3b2d1667bb
commit 3d9032a386
11 changed files with 853 additions and 2 deletions

View File

@@ -67,3 +67,43 @@ def test_api_manual_registry_loop(tmp_path):
assert search_response.json()
finally:
app.dependency_overrides.clear()
def test_api_analysis_run_loop(tmp_path):
source = tmp_path / "repo"
source.mkdir()
(source / "README.md").write_text("# Searchable\n", encoding="utf-8")
(source / "package.json").write_text(
'{"dependencies":{"react":"latest","vite":"latest"}}',
encoding="utf-8",
)
def override_settings():
return Settings(database_path=str(tmp_path / "api-analysis.sqlite3"))
app.dependency_overrides[get_settings] = override_settings
client = TestClient(app)
try:
repository_response = client.post(
"/repos",
json={"name": "Frontend", "url": str(source)},
)
repository_id = repository_response.json()["id"]
run_response = client.post(f"/repos/{repository_id}/analysis-runs", json={})
assert run_response.status_code == 201
run = run_response.json()
assert run["analysis_run"]["status"] == "completed"
assert run["snapshot"]["file_count"] == 2
facts_response = client.get(f"/repos/{repository_id}/observed-facts")
assert facts_response.status_code == 200
fact_names = {
(fact["kind"], fact["name"], fact["path"])
for fact in facts_response.json()
}
assert ("documentation", "README", "README.md") in fact_names
assert ("framework", "React", "package.json") in fact_names
assert ("framework", "Vite", "package.json") in fact_names
finally:
app.dependency_overrides.clear()