From bf93f737aeec7b0ba6d007e867a55a8528615c23 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 27 Nov 2025 15:49:27 +0000 Subject: Task 2: Refactor owner push authorization test to fixture-first pattern MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Refactored test_push_authorized_by_owner_state to use fixture-first pattern - Test now creates its own TestContext and uses FixtureKind::RepoState - Uses git helper functions from fixtures.rs (clone_repo, create_deterministic_commit, try_push) - Follows the 3-step pattern: Generate fixtures → Send to relay → Verify behavior - Deprecated setup_repo_with_deterministic_commit with migration guide - Test passes: cargo test --test push_authorization test_push_authorized_by_owner_state - No API changes required for main project tests --- grasp-audit/src/fixtures.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'grasp-audit/src/fixtures.rs') diff --git a/grasp-audit/src/fixtures.rs b/grasp-audit/src/fixtures.rs index 45a413d..02e9810 100644 --- a/grasp-audit/src/fixtures.rs +++ b/grasp-audit/src/fixtures.rs @@ -1108,6 +1108,31 @@ impl Drop for RepoSetup { /// Set up a repository with deterministic commit for testing /// +/// # Deprecated +/// +/// This function is deprecated in favor of the fixture-first pattern. +/// Tests should create their own TestContext and use `FixtureKind::RepoState` +/// directly, following the Generate → Send → Verify pattern. +/// +/// See `test_push_authorized_by_owner_state` in `push_authorization.rs` for +/// an example of the fixture-first pattern. +/// +/// ## Migration Guide +/// +/// Instead of: +/// ```ignore +/// let setup = setup_repo_with_deterministic_commit(client, git_data_dir, relay_domain).await?; +/// ``` +/// +/// Use: +/// ```ignore +/// let ctx = TestContext::new(client); +/// let state_event = ctx.get_fixture(FixtureKind::RepoState).await?; +/// // Then clone, create deterministic commit, and push inline +/// ``` +/// +/// --- +/// /// This performs all the common setup steps needed for push authorization tests: /// 1. Gets RepoState fixture (repo announcement + state event with deterministic commit) /// 2. Extracts repo_id and npub @@ -1128,6 +1153,10 @@ impl Drop for RepoSetup { /// # Returns /// * `Ok(RepoSetup)` - The setup data /// * `Err(String)` - Error message if setup failed +#[deprecated( + since = "0.1.0", + note = "Use fixture-first pattern with TestContext and FixtureKind::RepoState instead. See test_push_authorized_by_owner_state for example." +)] pub async fn setup_repo_with_deterministic_commit( client: &crate::AuditClient, git_data_dir: &Path, -- cgit v1.2.3