diff options
Diffstat (limited to 'grasp-audit/src')
| -rw-r--r-- | grasp-audit/src/fixtures.rs | 15 | ||||
| -rw-r--r-- | grasp-audit/src/specs/grasp01/event_acceptance_policy.rs | 42 |
2 files changed, 15 insertions, 42 deletions
diff --git a/grasp-audit/src/fixtures.rs b/grasp-audit/src/fixtures.rs index e34ee6d..71d64d3 100644 --- a/grasp-audit/src/fixtures.rs +++ b/grasp-audit/src/fixtures.rs | |||
| @@ -199,18 +199,25 @@ impl<'a> TestContext<'a> { | |||
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | FixtureKind::RepoWithIssue => { | 201 | FixtureKind::RepoWithIssue => { |
| 202 | // First create repo | 202 | use nostr_sdk::prelude::*; |
| 203 | |||
| 204 | // First create and send repo | ||
| 203 | let test_name = format!("fixture-{:?}-{}", FixtureKind::ValidRepo, &uuid::Uuid::new_v4().to_string()[..8]); | 205 | let test_name = format!("fixture-{:?}-{}", FixtureKind::ValidRepo, &uuid::Uuid::new_v4().to_string()[..8]); |
| 204 | let repo = self.client.create_repo_announcement(&test_name).await?; | 206 | let repo = self.client.create_repo_announcement(&test_name).await?; |
| 205 | self.client.send_event(repo.clone()).await?; | 207 | self.client.send_event(repo.clone()).await?; |
| 206 | 208 | ||
| 207 | // Then create issue referencing it | 209 | // Then create issue referencing it - this will have 'a' tag to repo |
| 208 | self.client.create_issue( | 210 | // Note: We build the issue but DON'T send it here - the caller will send it |
| 211 | let issue = self.client.create_issue( | ||
| 209 | &repo, | 212 | &repo, |
| 210 | "Test Issue", | 213 | "Test Issue", |
| 211 | "Issue content for testing", | 214 | "Issue content for testing", |
| 212 | vec![], | 215 | vec![], |
| 213 | ) | 216 | )?; |
| 217 | |||
| 218 | // Return the issue - tests can extract repo reference from its 'a' tag | ||
| 219 | // The caller (create_fresh/get_or_create_shared) will send this event | ||
| 220 | Ok(issue) | ||
| 214 | } | 221 | } |
| 215 | 222 | ||
| 216 | FixtureKind::RepoWithComment => { | 223 | FixtureKind::RepoWithComment => { |
diff --git a/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs b/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs index 353d2c3..176b19a 100644 --- a/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs +++ b/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs | |||
| @@ -645,27 +645,10 @@ impl EventAcceptancePolicyTests { | |||
| 645 | // Create TestContext | 645 | // Create TestContext |
| 646 | let ctx = TestContext::new(client); | 646 | let ctx = TestContext::new(client); |
| 647 | 647 | ||
| 648 | // Get repo with issue fixture (mode-aware) | 648 | // Get repo with issue fixture (mode-aware) - returns the issue event |
| 649 | let repo_a = ctx.get_fixture(FixtureKind::RepoWithIssue).await | 649 | let issue_a = ctx.get_fixture(FixtureKind::RepoWithIssue).await |
| 650 | .map_err(|e| format!("Test setup failed: could not get repo with issue fixture: {}", e))?; | 650 | .map_err(|e| format!("Test setup failed: could not get repo with issue fixture: {}", e))?; |
| 651 | 651 | ||
| 652 | // Extract the issue from the repo_a event (it's stored as the first 'e' tag) | ||
| 653 | let issue_a_id = repo_a.tags.iter() | ||
| 654 | .find(|t| t.kind() == TagKind::e()) | ||
| 655 | .and_then(|t| t.content()) | ||
| 656 | .ok_or("Missing issue reference in RepoWithIssue fixture")?; | ||
| 657 | |||
| 658 | // Query to get the actual issue event | ||
| 659 | let filter = Filter::new().id( | ||
| 660 | nostr_sdk::EventId::from_hex(issue_a_id) | ||
| 661 | .map_err(|e| format!("Invalid issue ID: {}", e))? | ||
| 662 | ); | ||
| 663 | let issues = client.query(filter).await | ||
| 664 | .map_err(|e| format!("Failed to query issue: {}", e))?; | ||
| 665 | let issue_a = issues.first() | ||
| 666 | .ok_or("Issue not found")? | ||
| 667 | .clone(); | ||
| 668 | |||
| 669 | // Create Repo B but DON'T send it (unaccepted) - just for creating Issue B | 652 | // Create Repo B but DON'T send it (unaccepted) - just for creating Issue B |
| 670 | let repo_b = Self::create_test_repo(client, "repo-b").await?; | 653 | let repo_b = Self::create_test_repo(client, "repo-b").await?; |
| 671 | 654 | ||
| @@ -701,27 +684,10 @@ impl EventAcceptancePolicyTests { | |||
| 701 | // Create TestContext | 684 | // Create TestContext |
| 702 | let ctx = TestContext::new(client); | 685 | let ctx = TestContext::new(client); |
| 703 | 686 | ||
| 704 | // Get repo with issue fixture (mode-aware) | 687 | // Get repo with issue fixture (mode-aware) - returns the issue event |
| 705 | let repo = ctx.get_fixture(FixtureKind::RepoWithIssue).await | 688 | let issue = ctx.get_fixture(FixtureKind::RepoWithIssue).await |
| 706 | .map_err(|e| format!("Test setup failed: could not get repo with issue fixture: {}", e))?; | 689 | .map_err(|e| format!("Test setup failed: could not get repo with issue fixture: {}", e))?; |
| 707 | 690 | ||
| 708 | // Extract the issue from the repo event (it's stored as the first 'e' tag) | ||
| 709 | let issue_id = repo.tags.iter() | ||
| 710 | .find(|t| t.kind() == TagKind::e()) | ||
| 711 | .and_then(|t| t.content()) | ||
| 712 | .ok_or("Missing issue reference in RepoWithIssue fixture")?; | ||
| 713 | |||
| 714 | // Query to get the actual issue event | ||
| 715 | let filter = Filter::new().id( | ||
| 716 | nostr_sdk::EventId::from_hex(issue_id) | ||
| 717 | .map_err(|e| format!("Invalid issue ID: {}", e))? | ||
| 718 | ); | ||
| 719 | let issues = client.query(filter).await | ||
| 720 | .map_err(|e| format!("Failed to query issue: {}", e))?; | ||
| 721 | let issue = issues.first() | ||
| 722 | .ok_or("Issue not found")? | ||
| 723 | .clone(); | ||
| 724 | |||
| 725 | // Create comment using the helper (which adds NIP-22 tags including 'E') | 691 | // Create comment using the helper (which adds NIP-22 tags including 'E') |
| 726 | let comment = Self::create_comment_for_event(client, &issue, "Comment content")?; | 692 | let comment = Self::create_comment_for_event(client, &issue, "Comment content")?; |
| 727 | 693 | ||