diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/git_remote_nostr/push.rs | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/tests/git_remote_nostr/push.rs b/tests/git_remote_nostr/push.rs index 8498958..6467dec 100644 --- a/tests/git_remote_nostr/push.rs +++ b/tests/git_remote_nostr/push.rs | |||
| @@ -2003,6 +2003,125 @@ async fn push_with_escaped_newlines_in_description_creates_pr_with_multiline_des | |||
| 2003 | Ok(()) | 2003 | Ok(()) |
| 2004 | } | 2004 | } |
| 2005 | 2005 | ||
| 2006 | #[tokio::test] | ||
| 2007 | #[serial] | ||
| 2008 | async fn force_push_to_existing_patch_series_with_title_description_options_creates_patches_with_custom_cover_letter() | ||
| 2009 | -> Result<()> { | ||
| 2010 | let (events, source_git_repo) = prep_source_repo_and_events_including_proposals().await?; | ||
| 2011 | let _source_path = source_git_repo.dir.to_str().unwrap().to_string(); | ||
| 2012 | |||
| 2013 | let (mut r51, mut r52, mut r53, mut r55, mut r56, mut r57) = ( | ||
| 2014 | Relay::new(8051, None, None), | ||
| 2015 | Relay::new(8052, None, None), | ||
| 2016 | Relay::new(8053, None, None), | ||
| 2017 | Relay::new(8055, None, None), | ||
| 2018 | Relay::new(8056, None, None), | ||
| 2019 | Relay::new(8057, None, None), | ||
| 2020 | ); | ||
| 2021 | r51.events = events.clone(); | ||
| 2022 | r55.events = events.clone(); | ||
| 2023 | |||
| 2024 | #[allow(clippy::mutable_key_type)] | ||
| 2025 | let before = r55.events.iter().cloned().collect::<HashSet<Event>>(); | ||
| 2026 | |||
| 2027 | let cli_tester_handle = std::thread::spawn(move || -> Result<String> { | ||
| 2028 | let branch_name = get_proposal_branch_name_from_events(&events, FEATURE_BRANCH_NAME_1)?; | ||
| 2029 | |||
| 2030 | let git_repo = clone_git_repo_with_nostr_url()?; | ||
| 2031 | git_repo.checkout_remote_branch(&branch_name)?; | ||
| 2032 | |||
| 2033 | // Create two new commits to replace the existing patch series | ||
| 2034 | std::fs::write(git_repo.dir.join("new1.txt"), "content 1")?; | ||
| 2035 | git_repo.stage_and_commit("add new1")?; | ||
| 2036 | |||
| 2037 | std::fs::write(git_repo.dir.join("new2.txt"), "content 2")?; | ||
| 2038 | git_repo.stage_and_commit("add new2")?; | ||
| 2039 | |||
| 2040 | // Force push with custom title and description | ||
| 2041 | let mut p = CliTester::new_git_with_remote_helper_from_dir( | ||
| 2042 | &git_repo.dir, | ||
| 2043 | [ | ||
| 2044 | "push", | ||
| 2045 | "--force", | ||
| 2046 | "--push-option=title=Custom Patch Title", | ||
| 2047 | "--push-option=description=Custom patch series description", | ||
| 2048 | "origin", | ||
| 2049 | &branch_name, | ||
| 2050 | ], | ||
| 2051 | ); | ||
| 2052 | cli_expect_nostr_fetch(&mut p)?; | ||
| 2053 | p.expect("git servers: listing refs...\r\n")?; | ||
| 2054 | p.expect_eventually_and_print(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; | ||
| 2055 | let output = p.expect_end_eventually()?; | ||
| 2056 | |||
| 2057 | for p in [51, 52, 53, 55, 56, 57] { | ||
| 2058 | relay::shutdown_relay(8000 + p)?; | ||
| 2059 | } | ||
| 2060 | |||
| 2061 | Ok(output) | ||
| 2062 | }); | ||
| 2063 | let _ = join!( | ||
| 2064 | r51.listen_until_close(), | ||
| 2065 | r52.listen_until_close(), | ||
| 2066 | r53.listen_until_close(), | ||
| 2067 | r55.listen_until_close(), | ||
| 2068 | r56.listen_until_close(), | ||
| 2069 | r57.listen_until_close(), | ||
| 2070 | ); | ||
| 2071 | |||
| 2072 | let output = cli_tester_handle.join().unwrap()?; | ||
| 2073 | |||
| 2074 | // Verify the output shows the branch was pushed | ||
| 2075 | assert!(!output.is_empty(), "should have output from push"); | ||
| 2076 | |||
| 2077 | let new_events = r55 | ||
| 2078 | .events | ||
| 2079 | .iter() | ||
| 2080 | .cloned() | ||
| 2081 | .collect::<HashSet<Event>>() | ||
| 2082 | .difference(&before) | ||
| 2083 | .cloned() | ||
| 2084 | .collect::<Vec<Event>>(); | ||
| 2085 | |||
| 2086 | // Should create 5 events: 1 cover letter + 4 patches (2 existing + 2 new) | ||
| 2087 | assert_eq!( | ||
| 2088 | new_events.len(), | ||
| 2089 | 5, | ||
| 2090 | "should create 1 cover letter + 4 patch events" | ||
| 2091 | ); | ||
| 2092 | |||
| 2093 | // Find the cover letter | ||
| 2094 | let cover_letter = new_events | ||
| 2095 | .iter() | ||
| 2096 | .find(|e| e.kind.eq(&Kind::GitPatch) && e.content.contains("[PATCH 0/4]")) | ||
| 2097 | .expect("should have a cover letter event"); | ||
| 2098 | |||
| 2099 | // Check that the cover letter contains the custom title and description | ||
| 2100 | assert!( | ||
| 2101 | cover_letter.content.contains("Custom Patch Title"), | ||
| 2102 | "cover letter should contain custom title" | ||
| 2103 | ); | ||
| 2104 | |||
| 2105 | assert!( | ||
| 2106 | cover_letter | ||
| 2107 | .content | ||
| 2108 | .contains("Custom patch series description"), | ||
| 2109 | "cover letter content should contain custom description" | ||
| 2110 | ); | ||
| 2111 | |||
| 2112 | // Verify patches exist | ||
| 2113 | let patches: Vec<&Event> = new_events | ||
| 2114 | .iter() | ||
| 2115 | .filter(|e| { | ||
| 2116 | e.kind.eq(&Kind::GitPatch) && !e.content.contains("[PATCH 0/4]") // Exclude cover letter | ||
| 2117 | }) | ||
| 2118 | .collect(); | ||
| 2119 | |||
| 2120 | assert_eq!(patches.len(), 4, "should have 4 patch events"); | ||
| 2121 | |||
| 2122 | Ok(()) | ||
| 2123 | } | ||
| 2124 | |||
| 2006 | mod push_from_another_maintainer { | 2125 | mod push_from_another_maintainer { |
| 2007 | 2126 | ||
| 2008 | // TODO that has issued announcement | 2127 | // TODO that has issued announcement |