diff options
| -rw-r--r-- | src/sub_commands/prs/create.rs | 15 | ||||
| -rw-r--r-- | tests/prs_create.rs | 12 |
2 files changed, 15 insertions, 12 deletions
diff --git a/src/sub_commands/prs/create.rs b/src/sub_commands/prs/create.rs index e85611f..655978e 100644 --- a/src/sub_commands/prs/create.rs +++ b/src/sub_commands/prs/create.rs | |||
| @@ -298,6 +298,9 @@ mod tests_unique_and_duplicate { | |||
| 298 | } | 298 | } |
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | pub static PR_KIND: u64 = 318; | ||
| 302 | pub static PATCH_KIND: u64 = 317; | ||
| 303 | |||
| 301 | fn generate_pr_and_patch_events( | 304 | fn generate_pr_and_patch_events( |
| 302 | title: &String, | 305 | title: &String, |
| 303 | description: &String, | 306 | description: &String, |
| @@ -311,9 +314,9 @@ fn generate_pr_and_patch_events( | |||
| 311 | .context("failed to get root commit of the repository")?; | 314 | .context("failed to get root commit of the repository")?; |
| 312 | 315 | ||
| 313 | let pr_event = EventBuilder::new( | 316 | let pr_event = EventBuilder::new( |
| 314 | nostr::event::Kind::Custom(318), | 317 | nostr::event::Kind::Custom(PR_KIND), |
| 315 | format!("{title}\r\n\r\n{description}"), | 318 | format!("{title}\r\n\r\n{description}"), |
| 316 | &[Tag::Hashtag(format!("r-{root_commit}"))], | 319 | &[Tag::Reference(format!("r-{root_commit}"))], |
| 317 | // TODO: suggested branch name | 320 | // TODO: suggested branch name |
| 318 | // Tag::Generic( | 321 | // Tag::Generic( |
| 319 | // TagKind::Custom("suggested-branch-name".to_string()), | 322 | // TagKind::Custom("suggested-branch-name".to_string()), |
| @@ -335,14 +338,14 @@ fn generate_pr_and_patch_events( | |||
| 335 | .context("failed to create patch event")?; | 338 | .context("failed to create patch event")?; |
| 336 | events.push( | 339 | events.push( |
| 337 | EventBuilder::new( | 340 | EventBuilder::new( |
| 338 | nostr::event::Kind::Custom(317), | 341 | nostr::event::Kind::Custom(PATCH_KIND), |
| 339 | git_repo | 342 | git_repo |
| 340 | .make_patch_from_commit(commit) | 343 | .make_patch_from_commit(commit) |
| 341 | .context(format!("cannot make patch for commit {commit}"))?, | 344 | .context(format!("cannot make patch for commit {commit}"))?, |
| 342 | &[ | 345 | &[ |
| 343 | Tag::Hashtag(format!("r-{root_commit}")), | 346 | Tag::Reference(format!("r-{root_commit}")), |
| 344 | Tag::Hashtag(commit.to_string()), | 347 | Tag::Reference(commit.to_string()), |
| 345 | Tag::Hashtag(commit_parent.to_string()), | 348 | Tag::Reference(commit_parent.to_string()), |
| 346 | Tag::Event( | 349 | Tag::Event( |
| 347 | pr_event_id, | 350 | pr_event_id, |
| 348 | None, // TODO: add relay | 351 | None, // TODO: add relay |
diff --git a/tests/prs_create.rs b/tests/prs_create.rs index 3b8aa31..72a85c8 100644 --- a/tests/prs_create.rs +++ b/tests/prs_create.rs | |||
| @@ -420,8 +420,8 @@ mod sends_pr_and_2_patches_to_3_relays { | |||
| 420 | .find(|e| e.kind.as_u64().eq(&PR_KIND)) | 420 | .find(|e| e.kind.as_u64().eq(&PR_KIND)) |
| 421 | .unwrap(); | 421 | .unwrap(); |
| 422 | 422 | ||
| 423 | // root commit 't' tag | 423 | // root commit 'r' tag |
| 424 | assert!(pr_event.tags.iter().any(|t| t.as_vec()[0].eq("t") | 424 | assert!(pr_event.tags.iter().any(|t| t.as_vec()[0].eq("r") |
| 425 | && t.as_vec()[1].eq("r-9ee507fc4357d7ee16a5d8901bedcd103f23c17d"))); | 425 | && t.as_vec()[1].eq("r-9ee507fc4357d7ee16a5d8901bedcd103f23c17d"))); |
| 426 | } | 426 | } |
| 427 | Ok(()) | 427 | Ok(()) |
| @@ -444,12 +444,12 @@ mod sends_pr_and_2_patches_to_3_relays { | |||
| 444 | static COMMIT_ID: &str = "fe973a840fba2a8ab37dd505c154854a69a6505c"; | 444 | static COMMIT_ID: &str = "fe973a840fba2a8ab37dd505c154854a69a6505c"; |
| 445 | let most_recent_patch = patch_events[0]; | 445 | let most_recent_patch = patch_events[0]; |
| 446 | 446 | ||
| 447 | // commit 't' and 'commit' tag | 447 | // commit 'r' and 'commit' tag |
| 448 | assert!( | 448 | assert!( |
| 449 | most_recent_patch | 449 | most_recent_patch |
| 450 | .tags | 450 | .tags |
| 451 | .iter() | 451 | .iter() |
| 452 | .any(|t| t.as_vec()[0].eq("t") && t.as_vec()[1].eq(COMMIT_ID)) | 452 | .any(|t| t.as_vec()[0].eq("r") && t.as_vec()[1].eq(COMMIT_ID)) |
| 453 | ); | 453 | ); |
| 454 | assert!( | 454 | assert!( |
| 455 | most_recent_patch | 455 | most_recent_patch |
| @@ -464,14 +464,14 @@ mod sends_pr_and_2_patches_to_3_relays { | |||
| 464 | most_recent_patch | 464 | most_recent_patch |
| 465 | .tags | 465 | .tags |
| 466 | .iter() | 466 | .iter() |
| 467 | .any(|t| t.as_vec()[0].eq("t") && t.as_vec()[1].eq(COMMIT_PARENT_ID)) | 467 | .any(|t| t.as_vec()[0].eq("r") && t.as_vec()[1].eq(COMMIT_PARENT_ID)) |
| 468 | ); | 468 | ); |
| 469 | assert!(most_recent_patch.tags.iter().any( | 469 | assert!(most_recent_patch.tags.iter().any( |
| 470 | |t| t.as_vec()[0].eq("parent-commit") && t.as_vec()[1].eq(COMMIT_PARENT_ID) | 470 | |t| t.as_vec()[0].eq("parent-commit") && t.as_vec()[1].eq(COMMIT_PARENT_ID) |
| 471 | )); | 471 | )); |
| 472 | 472 | ||
| 473 | // root commit 't' tag | 473 | // root commit 't' tag |
| 474 | assert!(most_recent_patch.tags.iter().any(|t| t.as_vec()[0].eq("t") | 474 | assert!(most_recent_patch.tags.iter().any(|t| t.as_vec()[0].eq("r") |
| 475 | && t.as_vec()[1].eq("r-9ee507fc4357d7ee16a5d8901bedcd103f23c17d"))); | 475 | && t.as_vec()[1].eq("r-9ee507fc4357d7ee16a5d8901bedcd103f23c17d"))); |
| 476 | } | 476 | } |
| 477 | Ok(()) | 477 | Ok(()) |