|
12 | 12 | StalenessReport, |
13 | 13 | _read_frontmatter_value, |
14 | 14 | check_staleness, |
| 15 | + check_workspace_staleness, |
15 | 16 | compute_source_hash, |
16 | 17 | parse_doc_footer, |
17 | 18 | ) |
@@ -118,6 +119,38 @@ def test_filter_by_feature_name(self, help_dir: Path, project_root: Path) -> Non |
118 | 119 | assert report.help_entries[0].feature == "auth" |
119 | 120 |
|
120 | 121 |
|
| 122 | +class TestCheckWorkspaceStaleness: |
| 123 | + """Tests for check_workspace_staleness() convenience helper.""" |
| 124 | + |
| 125 | + def test_matches_direct_call(self, help_dir: Path, project_root: Path) -> None: |
| 126 | + """Helper produces the same report as the explicit-args API.""" |
| 127 | + # help_dir fixture creates .help/ under tmp_path; project_root == tmp_path. |
| 128 | + manifest = load_manifest(help_dir) |
| 129 | + direct = check_staleness(manifest, help_dir, project_root) |
| 130 | + via_helper = check_workspace_staleness(project_root) |
| 131 | + |
| 132 | + assert via_helper.stale_count == direct.stale_count |
| 133 | + assert sorted(e.feature for e in via_helper.help_entries) == sorted( |
| 134 | + e.feature for e in direct.help_entries |
| 135 | + ) |
| 136 | + |
| 137 | + def test_empty_report_when_no_manifest(self, tmp_path: Path) -> None: |
| 138 | + """A workspace without .help/features.yaml yields an empty report, not a raise.""" |
| 139 | + report = check_workspace_staleness(tmp_path) |
| 140 | + |
| 141 | + assert isinstance(report, StalenessReport) |
| 142 | + assert report.help_entries == [] |
| 143 | + assert report.doc_entries == [] |
| 144 | + assert report.stale_count == 0 |
| 145 | + |
| 146 | + def test_propagates_feature_filter(self, help_dir: Path, project_root: Path) -> None: |
| 147 | + """features= filter narrows the report just like the underlying API.""" |
| 148 | + report = check_workspace_staleness(project_root, features=["auth"]) |
| 149 | + |
| 150 | + assert len(report.help_entries) == 1 |
| 151 | + assert report.help_entries[0].feature == "auth" |
| 152 | + |
| 153 | + |
121 | 154 | class TestProjectDocFooterStaleness: |
122 | 155 | """Integration: project-doc generator writes a footer that check_staleness reads. |
123 | 156 |
|
|
0 commit comments