From 701668b02d999af42f51d8bd25fffb2a8692c3c8 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 16 Feb 2024 22:31:29 +0000 Subject: refactor: rename PR to proposal PR is a problematic term when it ambiguous whether the set of patches are PR-like or email-patch like. --- src/git.rs | 24 ++--- src/main.rs | 2 +- src/sub_commands/list.rs | 54 +++++------ src/sub_commands/pull.rs | 21 +++-- src/sub_commands/push.rs | 59 ++++++------ src/sub_commands/send.rs | 4 +- tests/list.rs | 236 +++++++++++++++++++++++------------------------ tests/pull.rs | 56 +++++------ tests/push.rs | 62 ++++++------- tests/send.rs | 95 ++++++++++--------- 10 files changed, 315 insertions(+), 298 deletions(-) diff --git a/src/git.rs b/src/git.rs index 13d56f3..faeb9f9 100644 --- a/src/git.rs +++ b/src/git.rs @@ -372,7 +372,7 @@ impl RepoActions for Repo { if let Ok(last_patch) = patches_to_apply.last().context("no patches") { last_patch } else { - self.checkout(branch_name).context("latest commit in pr doesnt connect with an existing commit. Try a git pull on master first.")?; + self.checkout(branch_name).context("latest commit in proposal doesnt connect with an existing commit. Try a git pull on master first.")?; return Ok(vec![]); }, "parent-commit", @@ -387,9 +387,9 @@ impl RepoActions for Repo { if let Ok(current_tip) = self.get_tip_of_local_branch(branch_name) { if !current_tip.to_string().eq(&parent_commit_id) { // TODO: either changes have been made on the local branch or - // the latest commit in the pr has rebased onto a newer commit - // that you havn't pulled yet ask user whether - // they want to proceed + // the latest commit in the prpoosal has rebased onto a newer + // commit that you havn't pulled yet ask user + // whether they want to proceed } } @@ -1408,20 +1408,22 @@ mod tests { use test_utils::TEST_KEY_1_KEYS; use super::*; - use crate::{repo_ref::RepoRef, sub_commands::send::generate_pr_and_patch_events}; + use crate::{ + repo_ref::RepoRef, sub_commands::send::generate_cover_letter_and_patch_events, + }; static BRANCH_NAME: &str = "add-example-feature"; - // returns original_repo, pr_event, patch_events + // returns original_repo, cover_letter_event, patch_events fn generate_test_repo_and_events() -> Result<(GitTestRepo, nostr::Event, Vec)> { let original_repo = GitTestRepo::default(); let oid3 = original_repo.populate_with_test_branch()?; let oid2 = original_repo.git_repo.find_commit(oid3)?.parent_id(0)?; let oid1 = original_repo.git_repo.find_commit(oid2)?.parent_id(0)?; - // TODO: generate pr and patch events + // TODO: generate cover_letter and patch events let git_repo = Repo::from_path(&original_repo.dir)?; - let mut events = generate_pr_and_patch_events( + let mut events = generate_cover_letter_and_patch_events( Some(("test".to_string(), "test".to_string())), &git_repo, &vec![oid_to_sha1(&oid1), oid_to_sha1(&oid2), oid_to_sha1(&oid3)], @@ -1441,7 +1443,7 @@ mod tests { use super::*; #[test] - fn branch_gets_created_with_name_specified_in_pr() -> Result<()> { + fn branch_gets_created_with_name_specified_in_proposal() -> Result<()> { let (_, _, patch_events) = generate_test_repo_and_events()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; @@ -1530,7 +1532,7 @@ mod tests { use super::*; #[test] - fn branch_gets_created_with_name_specified_in_pr() -> Result<()> { + fn branch_gets_created_with_name_specified_in_proposal() -> Result<()> { let (_, _, patch_events) = generate_test_repo_and_events()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; @@ -1609,7 +1611,7 @@ mod tests { } } - // TODO when_pr_root_is_tip_ahead_of_main_and_doesnt_exist + // TODO when_proposal_root_is_tip_ahead_of_main_and_doesnt_exist } mod when_branch_and_first_commits_exists { diff --git a/src/main.rs b/src/main.rs index 82a87c8..f60edd8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,7 +41,7 @@ enum Commands { List(sub_commands::list::SubCommandArgs), /// send new commits as proposal ammendments Push, - /// pull latest commits in pr linked to checked out branch + /// pull latest commits in proposal linked to checked out branch Pull, /// run with --nsec flag to change npub Login(sub_commands::login::SubCommandArgs), diff --git a/src/sub_commands/list.rs b/src/sub_commands/list.rs index 4764adc..b8c2919 100644 --- a/src/sub_commands/list.rs +++ b/src/sub_commands/list.rs @@ -46,21 +46,21 @@ pub async fn launch(_cli_args: &Cli, _args: &SubCommandArgs) -> Result<()> { ) .await?; - println!("finding PRs..."); + println!("finding proposals..."); - let pr_events: Vec = - find_pr_events(&client, &repo_ref, &root_commit.to_string()).await?; + let proposal_events: Vec = + find_proposal_events(&client, &repo_ref, &root_commit.to_string()).await?; - if pr_events.is_empty() { - println!("no PRs found... create one? try `ngit send`"); + if proposal_events.is_empty() { + println!("no proposals found... create one? try `ngit send`"); return Ok(()); } let selected_index = Interactor::default().choice( PromptChoiceParms::default() - .with_prompt("All PRs") + .with_prompt("all proposals") .with_choices( - pr_events + proposal_events .iter() .map(|e| { if let Ok(cl) = event_to_cover_letter(e) { @@ -78,26 +78,27 @@ pub async fn launch(_cli_args: &Cli, _args: &SubCommandArgs) -> Result<()> { println!("finding commits..."); let commits_events: Vec = - find_commits_for_pr_event(&client, &pr_events[selected_index], &repo_ref).await?; + find_commits_for_proposal_root_event(&client, &proposal_events[selected_index], &repo_ref) + .await?; confirm_checkout(&git_repo)?; - let most_recent_pr_patch_chain = get_most_recent_patch_with_ancestors(commits_events) - .context("cannot get most recent patch for PR")?; + let most_recent_proposal_patch_chain = get_most_recent_patch_with_ancestors(commits_events) + .context("cannot get most recent patch for proposal")?; - let branch_name: String = event_to_cover_letter(&pr_events[selected_index]) + let branch_name: String = event_to_cover_letter(&proposal_events[selected_index]) .context("cannot assign a branch name as event is not a patch set root")? .branch_name; let applied = git_repo - .apply_patch_chain(&branch_name, most_recent_pr_patch_chain) + .apply_patch_chain(&branch_name, most_recent_proposal_patch_chain) .context("cannot apply patch chain")?; if applied.is_empty() { - println!("checked out PR branch. no new commits to pull"); + println!("checked out proposal branch. no new commits to pull"); } else { println!( - "checked out PR branch. pulled {} new commits", + "checked out proposal branch. pulled {} new commits", applied.len(), ); } @@ -115,7 +116,7 @@ fn confirm_checkout(git_repo: &Repo) -> Result<()> { if git_repo.has_outstanding_changes()? { bail!( - "cannot pull PR branch when repository is not clean. discard or stash (un)staged changes and try again." + "cannot pull proposal branch when repository is not clean. discard or stash (un)staged changes and try again." ); } Ok(()) @@ -201,7 +202,7 @@ pub fn get_most_recent_patch_with_ancestors( Ok(res) } -pub async fn find_pr_events( +pub async fn find_proposal_events( #[cfg(test)] client: &crate::client::MockConnect, #[cfg(not(test))] client: &Client, repo_ref: &RepoRef, @@ -221,7 +222,8 @@ pub async fn find_pr_events( .iter() .map(|m| format!("{REPO_REF_KIND}:{m}:{}", repo_ref.identifier)), ), - // also pick up prs from the same repo but no target at our maintainers repo events + // also pick up proposals from the same repo but no target at our maintainers repo + // events nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) .custom_tag(nostr::Alphabet::T, vec!["root"]) @@ -229,7 +231,7 @@ pub async fn find_pr_events( ], ) .await - .context("cannot get pr events")? + .context("cannot get proposal events")? .iter() .filter(|e| { event_is_patch_set_root(e) @@ -250,10 +252,10 @@ pub async fn find_pr_events( .collect::>()) } -pub async fn find_commits_for_pr_event( +pub async fn find_commits_for_proposal_root_event( #[cfg(test)] client: &crate::client::MockConnect, #[cfg(not(test))] client: &Client, - pr_event: &nostr::Event, + proposal_root_event: &nostr::Event, repo_ref: &RepoRef, ) -> Result> { let mut patch_events: Vec = client @@ -265,7 +267,7 @@ pub async fn find_commits_for_pr_event( // this requires every patch to reference the root event // this will not pick up v2,v3 patch sets // TODO: fetch commits for v2.. patch sets - .event(pr_event.id), + .event(proposal_root_event.id), ], ) .await @@ -273,15 +275,15 @@ pub async fn find_commits_for_pr_event( .iter() .filter(|e| { e.kind.as_u64() == PATCH_KIND - && e.tags - .iter() - .any(|t| t.as_vec().len() > 2 && t.as_vec()[1].eq(&pr_event.id.to_string())) + && e.tags.iter().any(|t| { + t.as_vec().len() > 2 && t.as_vec()[1].eq(&proposal_root_event.id.to_string()) + }) }) .map(std::borrow::ToOwned::to_owned) .collect(); - if !event_is_cover_letter(pr_event) { - patch_events.push(pr_event.clone()); + if !event_is_cover_letter(proposal_root_event) { + patch_events.push(proposal_root_event.clone()); } Ok(patch_events) } diff --git a/src/sub_commands/pull.rs b/src/sub_commands/pull.rs index fc6db37..de078e3 100644 --- a/src/sub_commands/pull.rs +++ b/src/sub_commands/pull.rs @@ -9,7 +9,8 @@ use crate::{ git::{Repo, RepoActions}, repo_ref, sub_commands::{ - list::get_most_recent_patch_with_ancestors, push::fetch_pr_and_most_recent_patch_chain, + list::get_most_recent_patch_with_ancestors, + push::fetch_proposal_root_and_most_recent_patch_chain, }, }; @@ -29,7 +30,7 @@ pub async fn launch() -> Result<()> { .context("cannot get checked out branch name")?; if branch_name == main_or_master_branch_name { - bail!("checkout a branch associated with a PR first") + bail!("checkout a branch associated with a proposal first") } #[cfg(not(test))] let client = Client::default(); @@ -44,19 +45,23 @@ pub async fn launch() -> Result<()> { ) .await?; - let (_pr_event, commit_events) = - fetch_pr_and_most_recent_patch_chain(&client, &repo_ref, &root_commit, &branch_name) - .await?; + let (_proposal_root_event, commit_events) = fetch_proposal_root_and_most_recent_patch_chain( + &client, + &repo_ref, + &root_commit, + &branch_name, + ) + .await?; if git_repo.has_outstanding_changes()? { bail!("cannot pull changes when repository is not clean. discard changes and try again."); } - let most_recent_pr_patch_chain = get_most_recent_patch_with_ancestors(commit_events) - .context("cannot get most recent patch for PR")?; + let most_recent_proposal_patch_chain = get_most_recent_patch_with_ancestors(commit_events) + .context("cannot get most recent patch for proposal")?; let applied = git_repo - .apply_patch_chain(&branch_name, most_recent_pr_patch_chain) + .apply_patch_chain(&branch_name, most_recent_proposal_patch_chain) .context("cannot apply patch chain")?; if applied.is_empty() { diff --git a/src/sub_commands/push.rs b/src/sub_commands/push.rs index 7c6b95b..0fdd56f 100644 --- a/src/sub_commands/push.rs +++ b/src/sub_commands/push.rs @@ -12,7 +12,7 @@ use crate::{ repo_ref::{self, RepoRef}, sub_commands::{ list::{ - find_commits_for_pr_event, find_pr_events, get_commit_id_from_patch, + find_commits_for_proposal_root_event, find_proposal_events, get_commit_id_from_patch, get_most_recent_patch_with_ancestors, tag_value, }, send::{event_to_cover_letter, generate_patch_event, send_events}, @@ -36,7 +36,7 @@ pub async fn launch(cli_args: &Cli) -> Result<()> { .context("cannot get checked out branch name")?; if branch_name == main_or_master_branch_name { - bail!("checkout a branch associated with a PR first") + bail!("checkout a branch associated with a proposal first") } #[cfg(not(test))] let mut client = Client::default(); @@ -51,44 +51,48 @@ pub async fn launch(cli_args: &Cli) -> Result<()> { ) .await?; - let (pr_event, commit_events) = - fetch_pr_and_most_recent_patch_chain(&client, &repo_ref, &root_commit, &branch_name) - .await?; + let (proposal_root_event, commit_events) = fetch_proposal_root_and_most_recent_patch_chain( + &client, + &repo_ref, + &root_commit, + &branch_name, + ) + .await?; // TODO: fix these scenarios: - // - local PR branch is 2 behind and 1 ahead. intructions: ... - // - PR has been rebased. (against commit in main) instructions: ... - // - PR has been rebased. (against commit not in repo) instructions: .. + // - local proposal branch is 2 behind and 1 ahead. intructions: ... + // - proposal has been rebased. (against commit in main) instructions: ... + // - proposal has been rebased. (against commit not in repo) instructions: .. - let most_recent_pr_patch_chain = get_most_recent_patch_with_ancestors(commit_events) - .context("cannot get most recent patch for PR")?; + let most_recent_proposal_patch_chain = get_most_recent_patch_with_ancestors(commit_events) + .context("cannot get most recent patch for proposal")?; let branch_tip = git_repo.get_tip_of_local_branch(&branch_name)?; let most_recent_patch_commit_id = str_to_sha1( - &get_commit_id_from_patch(&most_recent_pr_patch_chain[0]) + &get_commit_id_from_patch(&most_recent_proposal_patch_chain[0]) .context("latest patch event doesnt have a commit tag")?, ) .context("latest patch event commit tag isn't a valid SHA1 hash")?; if most_recent_patch_commit_id.eq(&branch_tip) { - bail!("nostr pr already up-to-date with local branch"); + bail!("nostr proposal already up-to-date with local branch"); } - if most_recent_pr_patch_chain.iter().any(|e| { + if most_recent_proposal_patch_chain.iter().any(|e| { let c = tag_value(e, "parent-commit").unwrap_or_default(); c.eq(&branch_tip.to_string()) }) { - bail!("nostr pr is ahead of local branch"); + bail!("nostr proposal is ahead of local branch"); } let (ahead, behind) = git_repo .get_commits_ahead_behind(&most_recent_patch_commit_id, &branch_tip) - .context("the latest patch in pr doesnt share an ancestor with your branch.")?; + .context("the latest patch in proposal doesnt share an ancestor with your branch.")?; if !behind.is_empty() { bail!( - "your local pr branch is {} behind patches on nostr. consider rebasing or force pushing", + "your local proposal branch is {} behind patches on nostr. consider rebasing or force pushing", behind.len() ) } @@ -109,7 +113,7 @@ pub async fn launch(cli_args: &Cli) -> Result<()> { &git_repo, &root_commit, commit, - Some(pr_event.id), + Some(proposal_root_event.id), &keys, &repo_ref, patch_events.last().map(nostr::Event::id), @@ -135,33 +139,34 @@ pub async fn launch(cli_args: &Cli) -> Result<()> { Ok(()) } -pub async fn fetch_pr_and_most_recent_patch_chain( +pub async fn fetch_proposal_root_and_most_recent_patch_chain( #[cfg(test)] client: &crate::client::MockConnect, #[cfg(not(test))] client: &Client, repo_ref: &RepoRef, root_commit: &Sha1Hash, branch_name: &String, ) -> Result<(nostr::Event, Vec)> { - println!("finding PR event..."); + println!("finding proposal root event..."); - let pr_events: Vec = find_pr_events(client, repo_ref, &root_commit.to_string()) - .await - .context("cannot get pr events for repo")?; + let proposal_events: Vec = + find_proposal_events(client, repo_ref, &root_commit.to_string()) + .await + .context("cannot get proposal events for repo")?; - let pr_event: nostr::Event = pr_events + let proposal_root_event: nostr::Event = proposal_events .iter() .find(|e| { event_to_cover_letter(e).is_ok_and(|cl| cl.branch_name.eq(branch_name)) // TODO remove the dependancy on same branch name and replace with // references stored in .git/ngit }) - .context("cannot find a PR event associated with the checked out branch name")? + .context("cannot find a proposal root event associated with the checked out branch name")? .to_owned(); - println!("found PR event. finding commits..."); + println!("found proposal root event. finding commits..."); let commits_events: Vec = - find_commits_for_pr_event(client, &pr_event, repo_ref).await?; + find_commits_for_proposal_root_event(client, &proposal_root_event, repo_ref).await?; - Ok((pr_event, commits_events)) + Ok((proposal_root_event, commits_events)) } diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index b8cb271..3a9da4b 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs @@ -140,7 +140,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { // oldest first ahead.reverse(); - let events = generate_pr_and_patch_events( + let events = generate_cover_letter_and_patch_events( cover_letter_title_description.clone(), &git_repo, &ahead, @@ -369,7 +369,7 @@ mod tests_unique_and_duplicate { pub static PATCH_KIND: u64 = 1617; -pub fn generate_pr_and_patch_events( +pub fn generate_cover_letter_and_patch_events( cover_letter_title_description: Option<(String, String)>, git_repo: &Repo, commits: &Vec, diff --git a/tests/list.rs b/tests/list.rs index 4337d73..e072ff5 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -8,30 +8,30 @@ static FEATURE_BRANCH_NAME_2: &str = "feature-example-f"; static FEATURE_BRANCH_NAME_3: &str = "feature-example-c"; static FEATURE_BRANCH_NAME_4: &str = "feature-example-d"; -static PR_TITLE_1: &str = "pr a"; -static PR_TITLE_2: &str = "pr b"; -static PR_TITLE_3: &str = "pr c"; +static PROPOSAL_TITLE_1: &str = "proposal a"; +static PROPOSAL_TITLE_2: &str = "proposal b"; +static PROPOSAL_TITLE_3: &str = "proposal c"; -fn cli_tester_create_prs() -> Result { +fn cli_tester_create_proposals() -> Result { let git_repo = GitTestRepo::default(); git_repo.populate()?; - cli_tester_create_pr( + cli_tester_create_proposal( &git_repo, FEATURE_BRANCH_NAME_1, "a", - Some((PR_TITLE_1, "pr a description")), + Some((PROPOSAL_TITLE_1, "proposal a description")), )?; - cli_tester_create_pr( + cli_tester_create_proposal( &git_repo, FEATURE_BRANCH_NAME_2, "b", - Some((PR_TITLE_2, "pr b description")), + Some((PROPOSAL_TITLE_2, "proposal b description")), )?; - cli_tester_create_pr( + cli_tester_create_proposal( &git_repo, FEATURE_BRANCH_NAME_3, "c", - Some((PR_TITLE_3, "pr c description")), + Some((PROPOSAL_TITLE_3, "proposal c description")), )?; Ok(git_repo) } @@ -60,7 +60,7 @@ fn create_and_populate_branch( Ok(()) } -fn cli_tester_create_pr( +fn cli_tester_create_proposal( test_repo: &GitTestRepo, branch_name: &str, prefix: &str, @@ -158,8 +158,8 @@ mod cannot_find_repo_event { } .to_bech32()?, )?; - p.expect("finding PRs...\r\n")?; - p.expect_end_with("no PRs found... create one? try `ngit send`\r\n")?; + p.expect("finding proposals...\r\n")?; + p.expect_end_with("no proposals found... create one? try `ngit send`\r\n")?; } if naddr { let mut input = p.expect_input("repository naddr or nevent")?; @@ -172,8 +172,8 @@ mod cannot_find_repo_event { } .to_bech32()?, )?; - p.expect("finding PRs...\r\n")?; - p.expect_end_with("no PRs found... create one? try `ngit send`\r\n")?; + p.expect("finding proposals...\r\n")?; + p.expect_end_with("no proposals found... create one? try `ngit send`\r\n")?; p.expect_end_eventually()?; } @@ -220,17 +220,17 @@ mod cannot_find_repo_event { mod when_main_branch_is_uptodate { use super::*; - mod when_pr_branch_doesnt_exist { + mod when_proposal_branch_doesnt_exist { use super::*; mod when_main_is_checked_out { use super::*; - mod when_first_pr_selected { + mod when_first_proposal_selected { use super::*; - // TODO: test when other prs with the same name but from other repositories are - // present on relays + // TODO: test when other proposals with the same name but from other + // repositories are present on relays async fn prep_and_run() -> Result<(GitTestRepo, GitTestRepo)> { // fallback (51,52) user write (53, 55) repo (55, 56) let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( @@ -251,19 +251,19 @@ mod when_main_branch_is_uptodate { let cli_tester_handle = std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { - let originating_repo = cli_tester_create_prs()?; + let originating_repo = cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); - p.expect("finding PRs...\r\n")?; + p.expect("finding proposals...\r\n")?; let mut c = p.expect_choice( - "All PRs", + "all proposals", vec![ - format!("\"{PR_TITLE_1}\""), - format!("\"{PR_TITLE_2}\""), - format!("\"{PR_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_3}\""), ], )?; c.succeeds_with(0, true)?; @@ -293,7 +293,7 @@ mod when_main_branch_is_uptodate { mod cli_prompts { use super::*; - async fn run_async_prompts_to_choose_from_pr_titles() -> Result<()> { + async fn run_async_prompts_to_choose_from_proposal_titles() -> Result<()> { let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( Relay::new(8051, None, None), Relay::new(8052, None, None), @@ -311,26 +311,26 @@ mod when_main_branch_is_uptodate { r55.events.push(generate_test_key_1_relay_list_event()); let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - cli_tester_create_prs()?; + cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); - p.expect("finding PRs...\r\n")?; + p.expect("finding proposals...\r\n")?; let mut c = p.expect_choice( - "All PRs", + "all proposals", vec![ - format!("\"{PR_TITLE_1}\""), - format!("\"{PR_TITLE_2}\""), - format!("\"{PR_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_3}\""), ], )?; c.succeeds_with(0, true)?; p.expect("finding commits...\r\n")?; let mut confirm = p.expect_confirm("check out branch?", Some(true))?; confirm.succeeds_with(None)?; - p.expect("checked out PR branch. pulled 2 new commits\r\n")?; + p.expect("checked out proposal branch. pulled 2 new commits\r\n")?; p.expect_end()?; for p in [51, 52, 53, 55, 56] { @@ -354,15 +354,15 @@ mod when_main_branch_is_uptodate { #[tokio::test] #[serial] - async fn prompts_to_choose_from_pr_titles() -> Result<()> { - let _ = run_async_prompts_to_choose_from_pr_titles().await; + async fn prompts_to_choose_from_proposal_titles() -> Result<()> { + let _ = run_async_prompts_to_choose_from_proposal_titles().await; Ok(()) } } #[tokio::test] #[serial] - async fn pr_branch_created_with_correct_name() -> Result<()> { + async fn proposal_branch_created_with_correct_name() -> Result<()> { let (_, test_repo) = prep_and_run().await?; assert_eq!( vec![FEATURE_BRANCH_NAME_1, "main"], @@ -373,7 +373,7 @@ mod when_main_branch_is_uptodate { #[tokio::test] #[serial] - async fn pr_branch_checked_out() -> Result<()> { + async fn proposal_branch_checked_out() -> Result<()> { let (_, test_repo) = prep_and_run().await?; assert_eq!( FEATURE_BRANCH_NAME_1, @@ -384,7 +384,7 @@ mod when_main_branch_is_uptodate { #[tokio::test] #[serial] - async fn pr_branch_tip_is_most_recent_patch() -> Result<()> { + async fn proposal_branch_tip_is_most_recent_patch() -> Result<()> { let (originating_repo, test_repo) = prep_and_run().await?; assert_eq!( originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, @@ -393,7 +393,7 @@ mod when_main_branch_is_uptodate { Ok(()) } } - mod when_third_pr_selected { + mod when_third_proposal_selected { use super::*; async fn prep_and_run() -> Result<(GitTestRepo, GitTestRepo)> { @@ -416,19 +416,19 @@ mod when_main_branch_is_uptodate { let cli_tester_handle = std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { - let originating_repo = cli_tester_create_prs()?; + let originating_repo = cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); - p.expect("finding PRs...\r\n")?; + p.expect("finding proposals...\r\n")?; let mut c = p.expect_choice( - "All PRs", + "all proposals", vec![ - format!("\"{PR_TITLE_1}\""), - format!("\"{PR_TITLE_2}\""), - format!("\"{PR_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_3}\""), ], )?; c.succeeds_with(2, true)?; @@ -458,7 +458,7 @@ mod when_main_branch_is_uptodate { mod cli_prompts { use super::*; - async fn run_async_prompts_to_choose_from_pr_titles() -> Result<()> { + async fn run_async_prompts_to_choose_from_proposal_titles() -> Result<()> { let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( Relay::new(8051, None, None), Relay::new(8052, None, None), @@ -476,26 +476,26 @@ mod when_main_branch_is_uptodate { r55.events.push(generate_test_key_1_relay_list_event()); let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - cli_tester_create_prs()?; + cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); - p.expect("finding PRs...\r\n")?; + p.expect("finding proposals...\r\n")?; let mut c = p.expect_choice( - "All PRs", + "all proposals", vec![ - format!("\"{PR_TITLE_1}\""), - format!("\"{PR_TITLE_2}\""), - format!("\"{PR_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_3}\""), ], )?; c.succeeds_with(2, true)?; p.expect("finding commits...\r\n")?; let mut confirm = p.expect_confirm("check out branch?", Some(true))?; confirm.succeeds_with(None)?; - p.expect("checked out PR branch. pulled 2 new commits\r\n")?; + p.expect("checked out proposal branch. pulled 2 new commits\r\n")?; p.expect_end()?; for p in [51, 52, 53, 55, 56] { @@ -519,15 +519,15 @@ mod when_main_branch_is_uptodate { #[tokio::test] #[serial] - async fn prompts_to_choose_from_pr_titles() -> Result<()> { - let _ = run_async_prompts_to_choose_from_pr_titles().await; + async fn prompts_to_choose_from_proposal_titles() -> Result<()> { + let _ = run_async_prompts_to_choose_from_proposal_titles().await; Ok(()) } } #[tokio::test] #[serial] - async fn pr_branch_created_with_correct_name() -> Result<()> { + async fn proposal_branch_created_with_correct_name() -> Result<()> { let (_, test_repo) = prep_and_run().await?; assert_eq!( vec![FEATURE_BRANCH_NAME_3, "main"], @@ -538,7 +538,7 @@ mod when_main_branch_is_uptodate { #[tokio::test] #[serial] - async fn pr_branch_checked_out() -> Result<()> { + async fn proposal_branch_checked_out() -> Result<()> { let (_, test_repo) = prep_and_run().await?; assert_eq!( FEATURE_BRANCH_NAME_3, @@ -549,7 +549,7 @@ mod when_main_branch_is_uptodate { #[tokio::test] #[serial] - async fn pr_branch_tip_is_most_recent_patch() -> Result<()> { + async fn proposal_branch_tip_is_most_recent_patch() -> Result<()> { let (originating_repo, test_repo) = prep_and_run().await?; assert_eq!( originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_3)?, @@ -558,7 +558,7 @@ mod when_main_branch_is_uptodate { Ok(()) } } - mod when_forth_pr_has_no_cover_letter { + mod when_forth_proposal_has_no_cover_letter { use super::*; async fn prep_and_run() -> Result<(GitTestRepo, GitTestRepo)> { @@ -581,8 +581,8 @@ mod when_main_branch_is_uptodate { let cli_tester_handle = std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { - let originating_repo = cli_tester_create_prs()?; - cli_tester_create_pr( + let originating_repo = cli_tester_create_proposals()?; + cli_tester_create_proposal( &originating_repo, FEATURE_BRANCH_NAME_4, "d", @@ -592,13 +592,13 @@ mod when_main_branch_is_uptodate { test_repo.populate()?; let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); - p.expect("finding PRs...\r\n")?; + p.expect("finding proposals...\r\n")?; let mut c = p.expect_choice( - "All PRs", + "all proposals", vec![ - format!("\"{PR_TITLE_1}\""), - format!("\"{PR_TITLE_2}\""), - format!("\"{PR_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_3}\""), format!("add d3.md"), // commit msg title ], )?; @@ -629,7 +629,7 @@ mod when_main_branch_is_uptodate { mod cli_prompts { use super::*; - async fn run_async_prompts_to_choose_from_pr_titles() -> Result<()> { + async fn run_async_prompts_to_choose_from_proposal_titles() -> Result<()> { let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( Relay::new(8051, None, None), Relay::new(8052, None, None), @@ -647,8 +647,8 @@ mod when_main_branch_is_uptodate { r55.events.push(generate_test_key_1_relay_list_event()); let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - let originating_repo = cli_tester_create_prs()?; - cli_tester_create_pr( + let originating_repo = cli_tester_create_proposals()?; + cli_tester_create_proposal( &originating_repo, FEATURE_BRANCH_NAME_4, "d", @@ -658,13 +658,13 @@ mod when_main_branch_is_uptodate { test_repo.populate()?; let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); - p.expect("finding PRs...\r\n")?; + p.expect("finding proposals...\r\n")?; let mut c = p.expect_choice( - "All PRs", + "all proposals", vec![ - format!("\"{PR_TITLE_1}\""), - format!("\"{PR_TITLE_2}\""), - format!("\"{PR_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_3}\""), format!("add d3.md"), // commit msg title ], )?; @@ -672,7 +672,7 @@ mod when_main_branch_is_uptodate { p.expect("finding commits...\r\n")?; let mut confirm = p.expect_confirm("check out branch?", Some(true))?; confirm.succeeds_with(None)?; - p.expect("checked out PR branch. pulled 2 new commits\r\n")?; + p.expect("checked out proposal branch. pulled 2 new commits\r\n")?; p.expect_end()?; for p in [51, 52, 53, 55, 56] { @@ -696,15 +696,15 @@ mod when_main_branch_is_uptodate { #[tokio::test] #[serial] - async fn prompts_to_choose_from_pr_titles() -> Result<()> { - let _ = run_async_prompts_to_choose_from_pr_titles().await; + async fn prompts_to_choose_from_proposal_titles() -> Result<()> { + let _ = run_async_prompts_to_choose_from_proposal_titles().await; Ok(()) } } #[tokio::test] #[serial] - async fn pr_branch_created_with_correct_name() -> Result<()> { + async fn proposal_branch_created_with_correct_name() -> Result<()> { let (_, test_repo) = prep_and_run().await?; assert_eq!( vec![FEATURE_BRANCH_NAME_4, "main"], @@ -715,7 +715,7 @@ mod when_main_branch_is_uptodate { #[tokio::test] #[serial] - async fn pr_branch_checked_out() -> Result<()> { + async fn proposal_branch_checked_out() -> Result<()> { let (_, test_repo) = prep_and_run().await?; assert_eq!( FEATURE_BRANCH_NAME_4, @@ -726,7 +726,7 @@ mod when_main_branch_is_uptodate { #[tokio::test] #[serial] - async fn pr_branch_tip_is_most_recent_patch() -> Result<()> { + async fn proposal_branch_tip_is_most_recent_patch() -> Result<()> { let (originating_repo, test_repo) = prep_and_run().await?; assert_eq!( originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_4)?, @@ -738,7 +738,7 @@ mod when_main_branch_is_uptodate { } } - mod when_pr_branch_exists { + mod when_proposal_branch_exists { use super::*; mod when_main_is_checked_out { @@ -766,7 +766,7 @@ mod when_main_branch_is_uptodate { let cli_tester_handle = std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { - let originating_repo = cli_tester_create_prs()?; + let originating_repo = cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; @@ -779,13 +779,13 @@ mod when_main_branch_is_uptodate { false, )?; test_repo.checkout("main")?; - p.expect("finding PRs...\r\n")?; + p.expect("finding proposals...\r\n")?; let mut c = p.expect_choice( - "All PRs", + "all proposals", vec![ - format!("\"{PR_TITLE_1}\""), - format!("\"{PR_TITLE_2}\""), - format!("\"{PR_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_3}\""), ], )?; c.succeeds_with(0, true)?; @@ -815,7 +815,7 @@ mod when_main_branch_is_uptodate { mod cli_prompts { use super::*; - async fn run_async_prompts_to_choose_from_pr_titles() -> Result<()> { + async fn run_async_prompts_to_choose_from_proposal_titles() -> Result<()> { let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( Relay::new(8051, None, None), Relay::new(8052, None, None), @@ -833,7 +833,7 @@ mod when_main_branch_is_uptodate { r55.events.push(generate_test_key_1_relay_list_event()); let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - cli_tester_create_prs()?; + cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; @@ -847,20 +847,20 @@ mod when_main_branch_is_uptodate { )?; test_repo.checkout("main")?; - p.expect("finding PRs...\r\n")?; + p.expect("finding proposals...\r\n")?; let mut c = p.expect_choice( - "All PRs", + "all proposals", vec![ - format!("\"{PR_TITLE_1}\""), - format!("\"{PR_TITLE_2}\""), - format!("\"{PR_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_3}\""), ], )?; c.succeeds_with(0, true)?; p.expect("finding commits...\r\n")?; let mut confirm = p.expect_confirm("check out branch?", Some(true))?; confirm.succeeds_with(None)?; - p.expect("checked out PR branch. no new commits to pull\r\n")?; + p.expect("checked out proposal branch. no new commits to pull\r\n")?; p.expect_end()?; for p in [51, 52, 53, 55, 56] { @@ -884,15 +884,15 @@ mod when_main_branch_is_uptodate { #[tokio::test] #[serial] - async fn prompts_to_choose_from_pr_titles() -> Result<()> { - let _ = run_async_prompts_to_choose_from_pr_titles().await; + async fn prompts_to_choose_from_proposal_titles() -> Result<()> { + let _ = run_async_prompts_to_choose_from_proposal_titles().await; Ok(()) } } #[tokio::test] #[serial] - async fn pr_branch_checked_out() -> Result<()> { + async fn proposal_branch_checked_out() -> Result<()> { let (_, test_repo) = prep_and_run().await?; assert_eq!( FEATURE_BRANCH_NAME_1, @@ -925,7 +925,7 @@ mod when_main_branch_is_uptodate { let cli_tester_handle = std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { - let originating_repo = cli_tester_create_prs()?; + let originating_repo = cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; @@ -939,13 +939,13 @@ mod when_main_branch_is_uptodate { )?; test_repo.checkout("main")?; - p.expect("finding PRs...\r\n")?; + p.expect("finding proposals...\r\n")?; let mut c = p.expect_choice( - "All PRs", + "all proposals", vec![ - format!("\"{PR_TITLE_1}\""), - format!("\"{PR_TITLE_2}\""), - format!("\"{PR_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_3}\""), ], )?; c.succeeds_with(0, true)?; @@ -975,7 +975,7 @@ mod when_main_branch_is_uptodate { mod cli_prompts { use super::*; - async fn run_async_prompts_to_choose_from_pr_titles() -> Result<()> { + async fn run_async_prompts_to_choose_from_proposal_titles() -> Result<()> { let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( Relay::new(8051, None, None), Relay::new(8052, None, None), @@ -993,7 +993,7 @@ mod when_main_branch_is_uptodate { r55.events.push(generate_test_key_1_relay_list_event()); let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - cli_tester_create_prs()?; + cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; @@ -1007,20 +1007,20 @@ mod when_main_branch_is_uptodate { )?; test_repo.checkout("main")?; - p.expect("finding PRs...\r\n")?; + p.expect("finding proposals...\r\n")?; let mut c = p.expect_choice( - "All PRs", + "all proposals", vec![ - format!("\"{PR_TITLE_1}\""), - format!("\"{PR_TITLE_2}\""), - format!("\"{PR_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_3}\""), ], )?; c.succeeds_with(0, true)?; p.expect("finding commits...\r\n")?; let mut confirm = p.expect_confirm("check out branch?", Some(true))?; confirm.succeeds_with(None)?; - p.expect("checked out PR branch. pulled 1 new commits\r\n")?; + p.expect("checked out proposal branch. pulled 1 new commits\r\n")?; p.expect_end()?; for p in [51, 52, 53, 55, 56] { @@ -1044,15 +1044,15 @@ mod when_main_branch_is_uptodate { #[tokio::test] #[serial] - async fn prompts_to_choose_from_pr_titles() -> Result<()> { - let _ = run_async_prompts_to_choose_from_pr_titles().await; + async fn prompts_to_choose_from_proposal_titles() -> Result<()> { + let _ = run_async_prompts_to_choose_from_proposal_titles().await; Ok(()) } } #[tokio::test] #[serial] - async fn pr_branch_checked_out() -> Result<()> { + async fn proposal_branch_checked_out() -> Result<()> { let (_, test_repo) = prep_and_run().await?; assert_eq!( FEATURE_BRANCH_NAME_1, @@ -1063,7 +1063,7 @@ mod when_main_branch_is_uptodate { #[tokio::test] #[serial] - async fn pr_branch_tip_is_most_recent_patch() -> Result<()> { + async fn proposal_branch_tip_is_most_recent_patch() -> Result<()> { let (originating_repo, test_repo) = prep_and_run().await?; assert_eq!( originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, @@ -1075,8 +1075,8 @@ mod when_main_branch_is_uptodate { mod when_branch_is_ahead { // use super::*; - // TODO latest commit in pr builds off an older commit in pr - // instead of previous. + // TODO latest commit in proposal builds off an older commit in + // proposal instead of previous. // TODO current git user created commit on branch } diff --git a/tests/pull.rs b/tests/pull.rs index d3064a3..7270908 100644 --- a/tests/pull.rs +++ b/tests/pull.rs @@ -7,33 +7,33 @@ static FEATURE_BRANCH_NAME_1: &str = "feature-example-t"; static FEATURE_BRANCH_NAME_2: &str = "feature-example-f"; static FEATURE_BRANCH_NAME_3: &str = "feature-example-c"; -static PR_TITLE_1: &str = "pr a"; -static PR_TITLE_2: &str = "pr b"; -static PR_TITLE_3: &str = "pr c"; +static PROPOSAL_TITLE_1: &str = "proposal a"; +static PROPOSAL_TITLE_2: &str = "proposal b"; +static PROPOSAL_TITLE_3: &str = "proposal c"; -fn cli_tester_create_prs() -> Result { +fn cli_tester_create_proposals() -> Result { let git_repo = GitTestRepo::default(); git_repo.populate()?; - cli_tester_create_pr( + cli_tester_create_proposal( &git_repo, FEATURE_BRANCH_NAME_1, "a", - PR_TITLE_1, - "pr a description", + PROPOSAL_TITLE_1, + "proposal a description", )?; - cli_tester_create_pr( + cli_tester_create_proposal( &git_repo, FEATURE_BRANCH_NAME_2, "b", - PR_TITLE_2, - "pr b description", + PROPOSAL_TITLE_2, + "proposal b description", )?; - cli_tester_create_pr( + cli_tester_create_proposal( &git_repo, FEATURE_BRANCH_NAME_3, "c", - PR_TITLE_3, - "pr c description", + PROPOSAL_TITLE_3, + "proposal c description", )?; Ok(git_repo) } @@ -62,7 +62,7 @@ fn create_and_populate_branch( Ok(()) } -fn cli_tester_create_pr( +fn cli_tester_create_proposal( test_repo: &GitTestRepo, branch_name: &str, prefix: &str, @@ -113,7 +113,7 @@ mod when_main_is_checked_out { r55.events.push(generate_test_key_1_relay_list_event()); let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - cli_tester_create_prs()?; + cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; @@ -122,7 +122,7 @@ mod when_main_is_checked_out { test_repo.checkout("main")?; let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); - p.expect("Error: checkout a branch associated with a PR first\r\n")?; + p.expect("Error: checkout a branch associated with a proposal first\r\n")?; p.expect_end()?; for p in [51, 52, 53, 55, 56] { @@ -174,7 +174,7 @@ mod when_branch_doesnt_exist { r55.events.push(generate_test_key_1_relay_list_event()); let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - cli_tester_create_prs()?; + cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; @@ -183,9 +183,9 @@ mod when_branch_doesnt_exist { test_repo.checkout("random-name")?; let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); - p.expect("finding PR event...\r\n")?; + p.expect("finding proposal event...\r\n")?; p.expect( - "Error: cannot find a PR event associated with the checked out branch name\r\n", + "Error: cannot find a proposal event associated with the checked out branch name\r\n", )?; p.expect_end()?; @@ -242,7 +242,7 @@ mod when_branch_is_checked_out { r55.events.push(generate_test_key_1_relay_list_event()); let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - cli_tester_create_prs()?; + cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; @@ -250,8 +250,8 @@ mod when_branch_is_checked_out { create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?; let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); - p.expect("finding PR event...\r\n")?; - p.expect("found PR event. finding commits...\r\n")?; + p.expect("finding proposal root event...\r\n")?; + p.expect("found proposal root event. finding commits...\r\n")?; p.expect("branch already up-to-date\r\n")?; p.expect_end()?; @@ -304,7 +304,7 @@ mod when_branch_is_checked_out { let cli_tester_handle = std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { - let originating_repo = cli_tester_create_prs()?; + let originating_repo = cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; @@ -356,7 +356,7 @@ mod when_branch_is_checked_out { let cli_tester_handle = std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { - let originating_repo = cli_tester_create_prs()?; + let originating_repo = cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; @@ -364,8 +364,8 @@ mod when_branch_is_checked_out { create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", true)?; let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); - p.expect("finding PR event...\r\n")?; - p.expect("found PR event. finding commits...\r\n")?; + p.expect("finding proposal root event...\r\n")?; + p.expect("found proposal root event. finding commits...\r\n")?; p.expect("applied 1 new commits\r\n")?; p.expect_end()?; @@ -397,7 +397,7 @@ mod when_branch_is_checked_out { #[tokio::test] #[serial] - async fn pr_branch_tip_is_most_recent_patch() -> Result<()> { + async fn proposal_branch_tip_is_most_recent_patch() -> Result<()> { let (originating_repo, test_repo) = prep_and_run().await?; assert_eq!( originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, @@ -409,7 +409,7 @@ mod when_branch_is_checked_out { mod when_branch_is_ahead { // use super::*; - // TODO latest commit in pr builds off an older commit in pr + // TODO latest commit in proposal builds off an older commit in proposal // instead of previous. // TODO current git user created commit on branch } diff --git a/tests/push.rs b/tests/push.rs index 07148ae..6f3a593 100644 --- a/tests/push.rs +++ b/tests/push.rs @@ -7,33 +7,33 @@ static FEATURE_BRANCH_NAME_1: &str = "feature-example-t"; static FEATURE_BRANCH_NAME_2: &str = "feature-example-f"; static FEATURE_BRANCH_NAME_3: &str = "feature-example-c"; -static PR_TITLE_1: &str = "pr a"; -static PR_TITLE_2: &str = "pr b"; -static PR_TITLE_3: &str = "pr c"; +static PROPOSAL_TITLE_1: &str = "proposal a"; +static PROPOSAL_TITLE_2: &str = "proposal b"; +static PROPOSAL_TITLE_3: &str = "proposal c"; -fn cli_tester_create_prs() -> Result { +fn cli_tester_create_proposals() -> Result { let git_repo = GitTestRepo::default(); git_repo.populate()?; - cli_tester_create_pr( + cli_tester_create_proposal( &git_repo, FEATURE_BRANCH_NAME_1, "a", - PR_TITLE_1, - "pr a description", + PROPOSAL_TITLE_1, + "proposal a description", )?; - cli_tester_create_pr( + cli_tester_create_proposal( &git_repo, FEATURE_BRANCH_NAME_2, "b", - PR_TITLE_2, - "pr b description", + PROPOSAL_TITLE_2, + "proposal b description", )?; - cli_tester_create_pr( + cli_tester_create_proposal( &git_repo, FEATURE_BRANCH_NAME_3, "c", - PR_TITLE_3, - "pr c description", + PROPOSAL_TITLE_3, + "proposal c description", )?; Ok(git_repo) } @@ -62,7 +62,7 @@ fn create_and_populate_branch( Ok(()) } -fn cli_tester_create_pr( +fn cli_tester_create_proposal( test_repo: &GitTestRepo, branch_name: &str, prefix: &str, @@ -100,13 +100,13 @@ mod when_main_is_checked_out { create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?; test_repo.checkout("main")?; let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]); - p.expect("Error: checkout a branch associated with a PR first\r\n")?; + p.expect("Error: checkout a branch associated with a proposal first\r\n")?; p.expect_end()?; Ok(()) } } -mod when_pr_isnt_associated_with_branch_name { +mod when_proposal_isnt_associated_with_branch_name { use super::*; mod cli_prompts { @@ -130,7 +130,7 @@ mod when_pr_isnt_associated_with_branch_name { r55.events.push(generate_test_key_1_relay_list_event()); let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - cli_tester_create_prs()?; + cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; @@ -139,9 +139,9 @@ mod when_pr_isnt_associated_with_branch_name { test_repo.checkout("random-name")?; let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]); - p.expect("finding PR event...\r\n")?; + p.expect("finding proposal root event...\r\n")?; p.expect( - "Error: cannot find a PR event associated with the checked out branch name\r\n", + "Error: cannot find a proposal root event associated with the checked out branch name\r\n", )?; p.expect_end()?; @@ -198,7 +198,7 @@ mod when_branch_is_checked_out { r55.events.push(generate_test_key_1_relay_list_event()); let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - cli_tester_create_prs()?; + cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; @@ -206,9 +206,9 @@ mod when_branch_is_checked_out { create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?; let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]); - p.expect("finding PR event...\r\n")?; - p.expect("found PR event. finding commits...\r\n")?; - p.expect("Error: nostr pr already up-to-date with local branch\r\n")?; + p.expect("finding proposal root event...\r\n")?; + p.expect("found proposal root event. finding commits...\r\n")?; + p.expect("Error: nostr proposal already up-to-date with local branch\r\n")?; p.expect_end()?; for p in [51, 52, 53, 55, 56] { @@ -261,7 +261,7 @@ mod when_branch_is_checked_out { r55.events.push(generate_test_key_1_relay_list_event()); let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - cli_tester_create_prs()?; + cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; @@ -269,9 +269,9 @@ mod when_branch_is_checked_out { create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", true)?; let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]); - p.expect("finding PR event...\r\n")?; - p.expect("found PR event. finding commits...\r\n")?; - p.expect("Error: nostr pr is ahead of local branch\r\n")?; + p.expect("finding proposal root event...\r\n")?; + p.expect("found proposal root event. finding commits...\r\n")?; + p.expect("Error: nostr proposal is ahead of local branch\r\n")?; p.expect_end()?; for p in [51, 52, 53, 55, 56] { @@ -329,7 +329,7 @@ mod when_branch_is_checked_out { let cli_tester_handle = std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { - let originating_repo = cli_tester_create_prs()?; + let originating_repo = cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; @@ -350,8 +350,8 @@ mod when_branch_is_checked_out { "push", ], ); - p.expect("finding PR event...\r\n")?; - p.expect("found PR event. finding commits...\r\n")?; + p.expect("finding proposal root event...\r\n")?; + p.expect("found proposal root event. finding commits...\r\n")?; p.expect( "1 commits ahead. preparing to create creating patch events.\r\n", )?; @@ -420,7 +420,7 @@ mod when_branch_is_checked_out { r55.events.push(generate_test_key_1_relay_list_event()); let cli_tester_handle = std::thread::spawn(move || -> Result { - cli_tester_create_prs()?; + cli_tester_create_proposals()?; let test_repo = GitTestRepo::default(); test_repo.populate()?; diff --git a/tests/send.rs b/tests/send.rs index 6d3e138..9c8561a 100644 --- a/tests/send.rs +++ b/tests/send.rs @@ -159,7 +159,7 @@ fn prep_git_repo() -> Result { Ok(test_repo) } -fn cli_tester_create_pr(git_repo: &GitTestRepo, include_cover_letter: bool) -> CliTester { +fn cli_tester_create_proposal(git_repo: &GitTestRepo, include_cover_letter: bool) -> CliTester { let mut args = vec![ "--nsec", TEST_KEY_1_NSEC, @@ -199,7 +199,7 @@ fn expect_msgs_first(p: &mut CliTester, include_cover_letter: bool) -> Result<() Ok(()) } -async fn prep_run_create_pr( +async fn prep_run_create_proposal( include_cover_letter: bool, ) -> Result<( Relay<'static>, @@ -245,7 +245,7 @@ async fn prep_run_create_pr( // // check relay had the right number of events let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - let mut p = cli_tester_create_pr(&git_repo, include_cover_letter); + let mut p = cli_tester_create_proposal(&git_repo, include_cover_letter); p.expect_end_eventually()?; for p in [51, 52, 53, 55, 56] { relay::shutdown_relay(8000 + p)?; @@ -270,8 +270,8 @@ mod sends_cover_letter_and_2_patches_to_3_relays { use super::*; #[tokio::test] #[serial] - async fn only_1_pr_kind_event_sent_to_each_relay() -> Result<()> { - let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; + async fn only_1_cover_letter_event_sent_to_each_relay() -> Result<()> { + let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?; for relay in [&r53, &r55, &r56] { assert_eq!( relay.events.iter().filter(|e| is_cover_letter(e)).count(), @@ -283,8 +283,8 @@ mod sends_cover_letter_and_2_patches_to_3_relays { #[tokio::test] #[serial] - async fn only_1_pr_kind_event_sent_to_user_relays() -> Result<()> { - let (_, _, r53, r55, _) = prep_run_create_pr(true).await?; + async fn only_1_cover_letter_event_sent_to_user_relays() -> Result<()> { + let (_, _, r53, r55, _) = prep_run_create_proposal(true).await?; for relay in [&r53, &r55] { assert_eq!( relay.events.iter().filter(|e| is_cover_letter(e)).count(), @@ -296,8 +296,8 @@ mod sends_cover_letter_and_2_patches_to_3_relays { #[tokio::test] #[serial] - async fn only_1_pr_kind_event_sent_to_repo_relays() -> Result<()> { - let (_, _, _, r55, r56) = prep_run_create_pr(true).await?; + async fn only_1_cover_letter_event_sent_to_repo_relays() -> Result<()> { + let (_, _, _, r55, r56) = prep_run_create_proposal(true).await?; for relay in [&r55, &r56] { assert_eq!( relay.events.iter().filter(|e| is_cover_letter(e)).count(), @@ -309,8 +309,8 @@ mod sends_cover_letter_and_2_patches_to_3_relays { #[tokio::test] #[serial] - async fn only_1_pr_kind_event_sent_to_fallback_relays() -> Result<()> { - let (r51, r52, _, _, _) = prep_run_create_pr(true).await?; + async fn only_1_cover_letter_event_sent_to_fallback_relays() -> Result<()> { + let (r51, r52, _, _, _) = prep_run_create_proposal(true).await?; for relay in [&r51, &r52] { assert_eq!( relay.events.iter().filter(|e| is_cover_letter(e)).count(), @@ -323,7 +323,7 @@ mod sends_cover_letter_and_2_patches_to_3_relays { #[tokio::test] #[serial] async fn only_2_patch_kind_events_sent_to_each_relay() -> Result<()> { - let (r51, r52, r53, r55, r56) = prep_run_create_pr(true).await?; + let (r51, r52, r53, r55, r56) = prep_run_create_proposal(true).await?; for relay in [&r51, &r52, &r53, &r55, &r56] { assert_eq!(relay.events.iter().filter(|e| is_patch(e)).count(), 2,); } @@ -334,7 +334,7 @@ mod sends_cover_letter_and_2_patches_to_3_relays { #[serial] async fn patch_content_contains_patch_in_email_format_with_patch_series_numbers() -> Result<()> { - let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; + let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?; for relay in [&r53, &r55, &r56] { let patch_events: Vec<&nostr::Event> = relay.events.iter().filter(|e| is_patch(e)).collect(); @@ -395,19 +395,19 @@ mod sends_cover_letter_and_2_patches_to_3_relays { Ok(()) } - mod pr_tags { + mod cover_letter_tags { use super::*; #[tokio::test] #[serial] async fn root_commit_as_r() -> Result<()> { - let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; + let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?; for relay in [&r53, &r55, &r56] { - let pr_event: &nostr::Event = + let cover_letter_event: &nostr::Event = relay.events.iter().find(|e| is_cover_letter(e)).unwrap(); assert_eq!( - pr_event + cover_letter_event .iter_tags() .find(|t| t.as_vec()[0].eq("r")) .unwrap() @@ -421,11 +421,11 @@ mod sends_cover_letter_and_2_patches_to_3_relays { #[tokio::test] #[serial] async fn a_tag_for_repo_event() -> Result<()> { - let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; + let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?; for relay in [&r53, &r55, &r56] { - let pr_event: &nostr::Event = + let cover_letter_event: &nostr::Event = relay.events.iter().find(|e| is_cover_letter(e)).unwrap(); - assert!(pr_event.iter_tags().any(|t| t.as_vec()[0].eq("a") + assert!(cover_letter_event.iter_tags().any(|t| t.as_vec()[0].eq("a") && t.as_vec()[1].eq(&format!( "{REPOSITORY_KIND}:{TEST_KEY_1_PUBKEY_HEX}:{}", generate_repo_ref_event().identifier().unwrap() @@ -443,13 +443,13 @@ mod sends_cover_letter_and_2_patches_to_3_relays { .unwrap() .as_vec() .clone()[1..]; - let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; + let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?; for relay in [&r53, &r55, &r56] { for m in maintainers { - let pr_event: &nostr::Event = + let cover_letter_event: &nostr::Event = relay.events.iter().find(|e| is_cover_letter(e)).unwrap(); assert!( - pr_event + cover_letter_event .iter_tags() .any(|t| { t.as_vec()[0].eq("p") && t.as_vec()[1].eq(m) }) ); @@ -461,12 +461,12 @@ mod sends_cover_letter_and_2_patches_to_3_relays { #[tokio::test] #[serial] async fn t_tag_cover_letter() -> Result<()> { - let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; + let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?; for relay in [&r53, &r55, &r56] { - let pr_event: &nostr::Event = + let cover_letter_event: &nostr::Event = relay.events.iter().find(|e| is_cover_letter(e)).unwrap(); assert!( - pr_event + cover_letter_event .iter_tags() .any(|t| { t.as_vec()[0].eq("t") && t.as_vec()[1].eq(&"cover-letter") }) ); @@ -477,12 +477,12 @@ mod sends_cover_letter_and_2_patches_to_3_relays { #[tokio::test] #[serial] async fn t_tag_root() -> Result<()> { - let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; + let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?; for relay in [&r53, &r55, &r56] { - let pr_event: &nostr::Event = + let cover_letter_event: &nostr::Event = relay.events.iter().find(|e| is_cover_letter(e)).unwrap(); assert!( - pr_event + cover_letter_event .iter_tags() .any(|t| { t.as_vec()[0].eq("t") && t.as_vec()[1].eq(&"root") }) ); @@ -493,14 +493,14 @@ mod sends_cover_letter_and_2_patches_to_3_relays { #[tokio::test] #[serial] async fn pr_tags_branch_name() -> Result<()> { - let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; + let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?; for relay in [&r53, &r55, &r56] { - let pr_event: &nostr::Event = + let cover_letter_event: &nostr::Event = relay.events.iter().find(|e| is_cover_letter(e)).unwrap(); // branch-name tag assert_eq!( - pr_event + cover_letter_event .iter_tags() .find(|t| t.as_vec()[0].eq("branch-name")) .unwrap() @@ -516,7 +516,7 @@ mod sends_cover_letter_and_2_patches_to_3_relays { use super::*; async fn prep() -> Result { - let (_, _, r53, _, _) = prep_run_create_pr(true).await?; + let (_, _, r53, _, _) = prep_run_create_proposal(true).await?; Ok(r53.events.iter().find(|e| is_patch(e)).unwrap().clone()) } @@ -649,14 +649,14 @@ mod sends_cover_letter_and_2_patches_to_3_relays { #[tokio::test] #[serial] - async fn patch_tags_pr_event_as_root() -> Result<()> { - let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; + async fn patch_tags_cover_letter_event_as_root() -> Result<()> { + let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?; for relay in [&r53, &r55, &r56] { let patch_events: Vec<&nostr::Event> = relay.events.iter().filter(|e| is_patch(e)).collect(); let most_recent_patch = patch_events[0]; - let pr_event = relay.events.iter().find(|e| is_cover_letter(e)).unwrap(); + let cover_letter_event = relay.events.iter().find(|e| is_cover_letter(e)).unwrap(); let root_event_tag = most_recent_patch .tags @@ -666,7 +666,10 @@ mod sends_cover_letter_and_2_patches_to_3_relays { }) .unwrap(); - assert_eq!(root_event_tag.as_vec()[1], pr_event.id.to_string()); + assert_eq!( + root_event_tag.as_vec()[1], + cover_letter_event.id.to_string() + ); } Ok(()) } @@ -674,7 +677,7 @@ mod sends_cover_letter_and_2_patches_to_3_relays { #[tokio::test] #[serial] async fn second_patch_tags_first_with_reply() -> Result<()> { - let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; + let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?; for relay in [&r53, &r55, &r56] { let patch_events = relay .events @@ -749,7 +752,7 @@ mod sends_cover_letter_and_2_patches_to_3_relays { // // check relay had the right number of events let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - let mut p = cli_tester_create_pr(&git_repo, true); + let mut p = cli_tester_create_proposal(&git_repo, true); expect_msgs_first(&mut p, true)?; relay::expect_send_with_progress( &mut p, @@ -840,7 +843,7 @@ mod sends_cover_letter_and_2_patches_to_3_relays { // // check relay had the right number of events let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - let mut p = cli_tester_create_pr(&git_repo, true); + let mut p = cli_tester_create_proposal(&git_repo, true); p.expect_end_eventually()?; for p in [51, 52, 53, 55, 56] { relay::shutdown_relay(8000 + p)?; @@ -919,7 +922,7 @@ mod sends_cover_letter_and_2_patches_to_3_relays { // // check relay had the right number of events let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - let mut p = cli_tester_create_pr(&git_repo, true); + let mut p = cli_tester_create_proposal(&git_repo, true); expect_msgs_first(&mut p, true)?; // p.expect_end_with("bla")?; relay::expect_send_with_progress( @@ -1011,7 +1014,7 @@ mod sends_2_patches_without_cover_letter { // // check relay had the right number of events let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - let mut p = cli_tester_create_pr(&git_repo, false); + let mut p = cli_tester_create_proposal(&git_repo, false); expect_msgs_first(&mut p, false)?; relay::expect_send_with_progress( @@ -1055,7 +1058,7 @@ mod sends_2_patches_without_cover_letter { #[tokio::test] #[serial] async fn no_cover_letter_event() -> Result<()> { - let (_, _, r53, r55, r56) = prep_run_create_pr(false).await?; + let (_, _, r53, r55, r56) = prep_run_create_proposal(false).await?; for relay in [&r53, &r55, &r56] { assert_eq!( relay.events.iter().filter(|e| is_cover_letter(e)).count(), @@ -1068,7 +1071,7 @@ mod sends_2_patches_without_cover_letter { #[tokio::test] #[serial] async fn two_patch_events() -> Result<()> { - let (_, _, r53, r55, r56) = prep_run_create_pr(false).await?; + let (_, _, r53, r55, r56) = prep_run_create_proposal(false).await?; for relay in [&r53, &r55, &r56] { assert_eq!(relay.events.iter().filter(|e| is_patch(e)).count(), 2); } @@ -1079,7 +1082,7 @@ mod sends_2_patches_without_cover_letter { #[serial] // TODO check this is the ancestor async fn first_patch_with_root_t_tag() -> Result<()> { - let (_, _, r53, r55, r56) = prep_run_create_pr(false).await?; + let (_, _, r53, r55, r56) = prep_run_create_proposal(false).await?; for relay in [&r53, &r55, &r56] { let patch_events = relay .events @@ -1106,7 +1109,7 @@ mod sends_2_patches_without_cover_letter { #[tokio::test] #[serial] async fn second_patch_lists_first_as_root() -> Result<()> { - let (_, _, r53, r55, r56) = prep_run_create_pr(false).await?; + let (_, _, r53, r55, r56) = prep_run_create_proposal(false).await?; for relay in [&r53, &r55, &r56] { let patch_events = relay .events -- cgit v1.2.3