From d4ef8cad0b95baa67e0f2803a7ec8601754a82a7 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 28 Feb 2024 16:38:39 +0000 Subject: fix: branch-name specified as main or master branch-name should be ommitted or ignored if patches created on main or master instead it should be infered based on commit msg --- tests/send.rs | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/send.rs b/tests/send.rs index 06f1b86..2c86566 100644 --- a/tests/send.rs +++ b/tests/send.rs @@ -1088,6 +1088,30 @@ mod sends_2_patches_without_cover_letter { Ok(()) } + #[tokio::test] + #[serial] + async fn root_patch_tags_branch_name() -> Result<()> { + let (_, _, r53, r55, r56) = prep_run_create_proposal(false).await?; + for relay in [&r53, &r55, &r56] { + let patch_events = relay + .events + .iter() + .filter(|e| is_patch(e)) + .collect::>(); + + // branch-name tag + assert_eq!( + patch_events[0] + .iter_tags() + .find(|t| t.as_vec()[0].eq("branch-name")) + .unwrap() + .as_vec()[1], + "feature" + ); + } + Ok(()) + } + #[tokio::test] #[serial] async fn second_patch_lists_first_as_root() -> Result<()> { @@ -1113,8 +1137,20 @@ mod sends_2_patches_without_cover_letter { Ok(()) } } -mod specify_starting_commits { +mod specify_starting_commits_whist_on_main_branch { use super::*; + + fn prep_git_repo() -> Result { + let test_repo = GitTestRepo::default(); + test_repo.populate()?; + // dont checkout feature branch + std::fs::write(test_repo.dir.join("t3.md"), "some content")?; + test_repo.stage_and_commit("add t3.md")?; + std::fs::write(test_repo.dir.join("t4.md"), "some content")?; + test_repo.stage_and_commit("add t4.md")?; + Ok(test_repo) + } + fn cli_tester_create_proposal(git_repo: &GitTestRepo) -> CliTester { let args = vec![ "--nsec", @@ -1144,6 +1180,7 @@ mod specify_starting_commits { Relay<'static>, )> { let git_repo = prep_git_repo()?; + // fallback (51,52) user write (53, 55) repo (55, 56) let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( Relay::new( @@ -1291,6 +1328,26 @@ mod specify_starting_commits { Ok(()) } + #[tokio::test] + #[serial] + async fn root_patch_doesnt_have_a_branch_name_tag() -> Result<()> { + let (_, _, r53, r55, r56) = prep_run_create_proposal().await?; + for relay in [&r53, &r55, &r56] { + let patch_events = relay + .events + .iter() + .filter(|e| is_patch(e)) + .collect::>(); + + assert!( + !patch_events[0] + .iter_tags() + .any(|t| t.as_vec()[0].eq("branch-name")) + ); + } + Ok(()) + } + #[tokio::test] #[serial] async fn first_patch_is_ancestor_and_root_others_in_correct_order() -> Result<()> { -- cgit v1.2.3