diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-27 15:55:13 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-27 15:55:13 +0000 |
| commit | 33a8870b6015fb989430edbbf5810a2d7d1a5247 (patch) | |
| tree | 48982bc839c2d5167eaccd963530b79acd6729ec /grasp-audit/src/fixtures.rs | |
| parent | bf93f737aeec7b0ba6d007e867a55a8528615c23 (diff) | |
Task 3: Refactor maintainer push authorization test to fixture-first pattern
- Deprecated setup_repo_for_maintainer helper
- test_push_authorized_by_maintainer_state_only now creates own TestContext
- Uses FixtureKind::RepoState and FixtureKind::MaintainerState
- Uses git helpers from fixtures.rs (clone_repo, create_deterministic_commit_with_variant, try_push)
- Uses CommitVariant::Maintainer and MAINTAINER_DETERMINISTIC_COMMIT_HASH
- Test compiles and passes: cargo test --lib (25 passed, 0 failed)
Diffstat (limited to 'grasp-audit/src/fixtures.rs')
| -rw-r--r-- | grasp-audit/src/fixtures.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/grasp-audit/src/fixtures.rs b/grasp-audit/src/fixtures.rs index 02e9810..571ab20 100644 --- a/grasp-audit/src/fixtures.rs +++ b/grasp-audit/src/fixtures.rs | |||
| @@ -1270,6 +1270,32 @@ pub async fn setup_repo_with_deterministic_commit( | |||
| 1270 | 1270 | ||
| 1271 | /// Set up a maintainer repository with deterministic commit (state only) | 1271 | /// Set up a maintainer repository with deterministic commit (state only) |
| 1272 | /// | 1272 | /// |
| 1273 | /// # Deprecated | ||
| 1274 | /// | ||
| 1275 | /// This function is deprecated in favor of the fixture-first pattern. | ||
| 1276 | /// Tests should create their own TestContext and use `FixtureKind::MaintainerState` | ||
| 1277 | /// directly, following the Generate → Send → Verify pattern. | ||
| 1278 | /// | ||
| 1279 | /// See `test_push_authorized_by_maintainer_state_only` in `push_authorization.rs` for | ||
| 1280 | /// an example of the fixture-first pattern. | ||
| 1281 | /// | ||
| 1282 | /// ## Migration Guide | ||
| 1283 | /// | ||
| 1284 | /// Instead of: | ||
| 1285 | /// ```ignore | ||
| 1286 | /// let setup = setup_repo_for_maintainer(client, git_data_dir, relay_domain).await?; | ||
| 1287 | /// ``` | ||
| 1288 | /// | ||
| 1289 | /// Use: | ||
| 1290 | /// ```ignore | ||
| 1291 | /// let ctx = TestContext::new(client); | ||
| 1292 | /// let _state_event = ctx.get_fixture(FixtureKind::RepoState).await?; | ||
| 1293 | /// let _maintainer_state = ctx.get_fixture(FixtureKind::MaintainerState).await?; | ||
| 1294 | /// // Then clone, create maintainer deterministic commit, and push inline | ||
| 1295 | /// ``` | ||
| 1296 | /// | ||
| 1297 | /// --- | ||
| 1298 | /// | ||
| 1273 | /// This performs all the common setup steps needed for maintainer push authorization tests: | 1299 | /// This performs all the common setup steps needed for maintainer push authorization tests: |
| 1274 | /// 1. Gets RepoState fixture (owner's repo announcement + state event with owner's deterministic commit) | 1300 | /// 1. Gets RepoState fixture (owner's repo announcement + state event with owner's deterministic commit) |
| 1275 | /// 2. Gets MaintainerState fixture (maintainer's state event ONLY - no announcement) | 1301 | /// 2. Gets MaintainerState fixture (maintainer's state event ONLY - no announcement) |
| @@ -1286,6 +1312,10 @@ pub async fn setup_repo_with_deterministic_commit( | |||
| 1286 | /// which publishes MaintainerAnnouncement separately. | 1312 | /// which publishes MaintainerAnnouncement separately. |
| 1287 | /// | 1313 | /// |
| 1288 | /// Returns RepoSetup which auto-cleans up the clone_path on drop | 1314 | /// Returns RepoSetup which auto-cleans up the clone_path on drop |
| 1315 | #[deprecated( | ||
| 1316 | since = "0.1.0", | ||
| 1317 | note = "Use fixture-first pattern with TestContext and FixtureKind::MaintainerState instead. See test_push_authorized_by_maintainer_state_only for example." | ||
| 1318 | )] | ||
| 1289 | pub async fn setup_repo_for_maintainer( | 1319 | pub async fn setup_repo_for_maintainer( |
| 1290 | client: &crate::AuditClient, | 1320 | client: &crate::AuditClient, |
| 1291 | git_data_dir: &Path, | 1321 | git_data_dir: &Path, |