upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/grasp-audit/src/fixtures.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-11-27 15:49:27 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-11-27 15:49:27 +0000
commitbf93f737aeec7b0ba6d007e867a55a8528615c23 (patch)
tree986dabfa0d1486d3f7b83c2a982e8424c296c964 /grasp-audit/src/fixtures.rs
parent6a77173127b5915c4c1b9219924e793795e0d051 (diff)
Task 2: Refactor owner push authorization test to fixture-first pattern
- 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
Diffstat (limited to 'grasp-audit/src/fixtures.rs')
-rw-r--r--grasp-audit/src/fixtures.rs29
1 files changed, 29 insertions, 0 deletions
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 {
1108 1108
1109/// Set up a repository with deterministic commit for testing 1109/// Set up a repository with deterministic commit for testing
1110/// 1110///
1111/// # Deprecated
1112///
1113/// This function is deprecated in favor of the fixture-first pattern.
1114/// Tests should create their own TestContext and use `FixtureKind::RepoState`
1115/// directly, following the Generate → Send → Verify pattern.
1116///
1117/// See `test_push_authorized_by_owner_state` in `push_authorization.rs` for
1118/// an example of the fixture-first pattern.
1119///
1120/// ## Migration Guide
1121///
1122/// Instead of:
1123/// ```ignore
1124/// let setup = setup_repo_with_deterministic_commit(client, git_data_dir, relay_domain).await?;
1125/// ```
1126///
1127/// Use:
1128/// ```ignore
1129/// let ctx = TestContext::new(client);
1130/// let state_event = ctx.get_fixture(FixtureKind::RepoState).await?;
1131/// // Then clone, create deterministic commit, and push inline
1132/// ```
1133///
1134/// ---
1135///
1111/// This performs all the common setup steps needed for push authorization tests: 1136/// This performs all the common setup steps needed for push authorization tests:
1112/// 1. Gets RepoState fixture (repo announcement + state event with deterministic commit) 1137/// 1. Gets RepoState fixture (repo announcement + state event with deterministic commit)
1113/// 2. Extracts repo_id and npub 1138/// 2. Extracts repo_id and npub
@@ -1128,6 +1153,10 @@ impl Drop for RepoSetup {
1128/// # Returns 1153/// # Returns
1129/// * `Ok(RepoSetup)` - The setup data 1154/// * `Ok(RepoSetup)` - The setup data
1130/// * `Err(String)` - Error message if setup failed 1155/// * `Err(String)` - Error message if setup failed
1156#[deprecated(
1157 since = "0.1.0",
1158 note = "Use fixture-first pattern with TestContext and FixtureKind::RepoState instead. See test_push_authorized_by_owner_state for example."
1159)]
1131pub async fn setup_repo_with_deterministic_commit( 1160pub async fn setup_repo_with_deterministic_commit(
1132 client: &crate::AuditClient, 1161 client: &crate::AuditClient,
1133 git_data_dir: &Path, 1162 git_data_dir: &Path,