generated from coulomb/repo-seed
Milestone 2’s core deterministic scanner path
This commit is contained in:
@@ -96,3 +96,51 @@ def test_capability_must_belong_to_repository(tmp_path):
|
||||
assert "ability" in str(exc)
|
||||
else:
|
||||
raise AssertionError("expected a NotFoundError")
|
||||
|
||||
|
||||
def test_analyze_repository_records_snapshot_and_observed_facts(tmp_path):
|
||||
source = tmp_path / "repo"
|
||||
source.mkdir()
|
||||
(source / "README.md").write_text("# Example\n", encoding="utf-8")
|
||||
(source / "requirements.txt").write_text("fastapi\n", encoding="utf-8")
|
||||
(source / "app.py").write_text(
|
||||
"from fastapi import FastAPI\n"
|
||||
"app = FastAPI()\n"
|
||||
'@app.get("/health")\n'
|
||||
"def health():\n"
|
||||
" return {}\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
service = make_service(tmp_path)
|
||||
repository = service.register_repository(
|
||||
name="Example",
|
||||
url=str(source),
|
||||
description="A local fixture repository",
|
||||
)
|
||||
|
||||
summary = service.analyze_repository(repository.id)
|
||||
|
||||
assert summary.analysis_run.status == "completed"
|
||||
assert summary.snapshot is not None
|
||||
assert summary.snapshot.file_count == 3
|
||||
assert service.get_repository(repository.id).status == "analyzed"
|
||||
fact_names = {(fact.kind, fact.name, fact.path) for fact in summary.facts}
|
||||
assert ("documentation", "README", "README.md") in fact_names
|
||||
assert ("framework", "FastAPI", "requirements.txt") in fact_names
|
||||
assert ("interface", "python route decorator", "app.py") in fact_names
|
||||
|
||||
|
||||
def test_analyze_repository_failure_is_recorded(tmp_path):
|
||||
service = make_service(tmp_path)
|
||||
repository = service.register_repository(
|
||||
name="Missing",
|
||||
url=str(tmp_path / "does-not-exist"),
|
||||
)
|
||||
|
||||
summary = service.analyze_repository(repository.id)
|
||||
|
||||
assert summary.analysis_run.status == "failed"
|
||||
assert summary.snapshot is None
|
||||
assert "does not exist" in (summary.analysis_run.error_message or "")
|
||||
assert service.get_repository(repository.id).status == "analysis_failed"
|
||||
|
||||
Reference in New Issue
Block a user