diff options
Diffstat (limited to 'tests/send.rs')
| -rw-r--r-- | tests/send.rs | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/tests/send.rs b/tests/send.rs index 06f1b86..2c86566 100644 --- a/tests/send.rs +++ b/tests/send.rs | |||
| @@ -1090,6 +1090,30 @@ mod sends_2_patches_without_cover_letter { | |||
| 1090 | 1090 | ||
| 1091 | #[tokio::test] | 1091 | #[tokio::test] |
| 1092 | #[serial] | 1092 | #[serial] |
| 1093 | async fn root_patch_tags_branch_name() -> Result<()> { | ||
| 1094 | let (_, _, r53, r55, r56) = prep_run_create_proposal(false).await?; | ||
| 1095 | for relay in [&r53, &r55, &r56] { | ||
| 1096 | let patch_events = relay | ||
| 1097 | .events | ||
| 1098 | .iter() | ||
| 1099 | .filter(|e| is_patch(e)) | ||
| 1100 | .collect::<Vec<&nostr::Event>>(); | ||
| 1101 | |||
| 1102 | // branch-name tag | ||
| 1103 | assert_eq!( | ||
| 1104 | patch_events[0] | ||
| 1105 | .iter_tags() | ||
| 1106 | .find(|t| t.as_vec()[0].eq("branch-name")) | ||
| 1107 | .unwrap() | ||
| 1108 | .as_vec()[1], | ||
| 1109 | "feature" | ||
| 1110 | ); | ||
| 1111 | } | ||
| 1112 | Ok(()) | ||
| 1113 | } | ||
| 1114 | |||
| 1115 | #[tokio::test] | ||
| 1116 | #[serial] | ||
| 1093 | async fn second_patch_lists_first_as_root() -> Result<()> { | 1117 | async fn second_patch_lists_first_as_root() -> Result<()> { |
| 1094 | let (_, _, r53, r55, r56) = prep_run_create_proposal(false).await?; | 1118 | let (_, _, r53, r55, r56) = prep_run_create_proposal(false).await?; |
| 1095 | for relay in [&r53, &r55, &r56] { | 1119 | for relay in [&r53, &r55, &r56] { |
| @@ -1113,8 +1137,20 @@ mod sends_2_patches_without_cover_letter { | |||
| 1113 | Ok(()) | 1137 | Ok(()) |
| 1114 | } | 1138 | } |
| 1115 | } | 1139 | } |
| 1116 | mod specify_starting_commits { | 1140 | mod specify_starting_commits_whist_on_main_branch { |
| 1117 | use super::*; | 1141 | use super::*; |
| 1142 | |||
| 1143 | fn prep_git_repo() -> Result<GitTestRepo> { | ||
| 1144 | let test_repo = GitTestRepo::default(); | ||
| 1145 | test_repo.populate()?; | ||
| 1146 | // dont checkout feature branch | ||
| 1147 | std::fs::write(test_repo.dir.join("t3.md"), "some content")?; | ||
| 1148 | test_repo.stage_and_commit("add t3.md")?; | ||
| 1149 | std::fs::write(test_repo.dir.join("t4.md"), "some content")?; | ||
| 1150 | test_repo.stage_and_commit("add t4.md")?; | ||
| 1151 | Ok(test_repo) | ||
| 1152 | } | ||
| 1153 | |||
| 1118 | fn cli_tester_create_proposal(git_repo: &GitTestRepo) -> CliTester { | 1154 | fn cli_tester_create_proposal(git_repo: &GitTestRepo) -> CliTester { |
| 1119 | let args = vec![ | 1155 | let args = vec![ |
| 1120 | "--nsec", | 1156 | "--nsec", |
| @@ -1144,6 +1180,7 @@ mod specify_starting_commits { | |||
| 1144 | Relay<'static>, | 1180 | Relay<'static>, |
| 1145 | )> { | 1181 | )> { |
| 1146 | let git_repo = prep_git_repo()?; | 1182 | let git_repo = prep_git_repo()?; |
| 1183 | |||
| 1147 | // fallback (51,52) user write (53, 55) repo (55, 56) | 1184 | // fallback (51,52) user write (53, 55) repo (55, 56) |
| 1148 | let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( | 1185 | let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( |
| 1149 | Relay::new( | 1186 | Relay::new( |
| @@ -1293,6 +1330,26 @@ mod specify_starting_commits { | |||
| 1293 | 1330 | ||
| 1294 | #[tokio::test] | 1331 | #[tokio::test] |
| 1295 | #[serial] | 1332 | #[serial] |
| 1333 | async fn root_patch_doesnt_have_a_branch_name_tag() -> Result<()> { | ||
| 1334 | let (_, _, r53, r55, r56) = prep_run_create_proposal().await?; | ||
| 1335 | for relay in [&r53, &r55, &r56] { | ||
| 1336 | let patch_events = relay | ||
| 1337 | .events | ||
| 1338 | .iter() | ||
| 1339 | .filter(|e| is_patch(e)) | ||
| 1340 | .collect::<Vec<&nostr::Event>>(); | ||
| 1341 | |||
| 1342 | assert!( | ||
| 1343 | !patch_events[0] | ||
| 1344 | .iter_tags() | ||
| 1345 | .any(|t| t.as_vec()[0].eq("branch-name")) | ||
| 1346 | ); | ||
| 1347 | } | ||
| 1348 | Ok(()) | ||
| 1349 | } | ||
| 1350 | |||
| 1351 | #[tokio::test] | ||
| 1352 | #[serial] | ||
| 1296 | async fn first_patch_is_ancestor_and_root_others_in_correct_order() -> Result<()> { | 1353 | async fn first_patch_is_ancestor_and_root_others_in_correct_order() -> Result<()> { |
| 1297 | let (_, _, r53, r55, r56) = prep_run_create_proposal().await?; | 1354 | let (_, _, r53, r55, r56) = prep_run_create_proposal().await?; |
| 1298 | for relay in [&r53, &r55, &r56] { | 1355 | for relay in [&r53, &r55, &r56] { |