diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/git_remote_nostr/list.rs | 23 | ||||
| -rw-r--r-- | tests/git_remote_nostr/push.rs | 42 | ||||
| -rw-r--r-- | tests/ngit_init.rs | 36 | ||||
| -rw-r--r-- | tests/ngit_list.rs | 378 | ||||
| -rw-r--r-- | tests/ngit_login.rs | 368 | ||||
| -rw-r--r-- | tests/ngit_send.rs | 253 |
6 files changed, 657 insertions, 443 deletions
diff --git a/tests/git_remote_nostr/list.rs b/tests/git_remote_nostr/list.rs index 37cff30..c201054 100644 --- a/tests/git_remote_nostr/list.rs +++ b/tests/git_remote_nostr/list.rs | |||
| @@ -41,7 +41,7 @@ mod without_state_announcement { | |||
| 41 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | 41 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { |
| 42 | let mut p = cli_tester_after_fetch(&git_repo)?; | 42 | let mut p = cli_tester_after_fetch(&git_repo)?; |
| 43 | p.send_line("list")?; | 43 | p.send_line("list")?; |
| 44 | p.expect(format!("fetching {} ref list over filesystem...\r\n", source_path).as_str())?; | 44 | p.expect(format!("fetching {source_path} ref list over filesystem...\r\n").as_str())?; |
| 45 | p.expect("list: connecting...\r\n\r\r\r")?; | 45 | p.expect("list: connecting...\r\n\r\r\r")?; |
| 46 | // println!("{}", p.expect_eventually("\r\n\r\n")?); | 46 | // println!("{}", p.expect_eventually("\r\n\r\n")?); |
| 47 | let res = p.expect_eventually("\r\n\r\n")?; | 47 | let res = p.expect_eventually("\r\n\r\n")?; |
| @@ -59,8 +59,8 @@ mod without_state_announcement { | |||
| 59 | .collect::<HashSet<String>>(), | 59 | .collect::<HashSet<String>>(), |
| 60 | HashSet::from([ | 60 | HashSet::from([ |
| 61 | "@refs/heads/main HEAD".to_string(), | 61 | "@refs/heads/main HEAD".to_string(), |
| 62 | format!("{} refs/heads/main", main_commit_id), | 62 | format!("{main_commit_id} refs/heads/main"), |
| 63 | format!("{} refs/heads/vnext", vnext_commit_id), | 63 | format!("{vnext_commit_id} refs/heads/vnext"), |
| 64 | ]), | 64 | ]), |
| 65 | ); | 65 | ); |
| 66 | Ok(()) | 66 | Ok(()) |
| @@ -120,7 +120,7 @@ mod with_state_announcement { | |||
| 120 | let mut p = cli_tester_after_fetch(&git_repo)?; | 120 | let mut p = cli_tester_after_fetch(&git_repo)?; |
| 121 | p.send_line("list")?; | 121 | p.send_line("list")?; |
| 122 | p.expect( | 122 | p.expect( |
| 123 | format!("fetching {} ref list over filesystem...\r\n", source_path).as_str(), | 123 | format!("fetching {source_path} ref list over filesystem...\r\n").as_str(), |
| 124 | )?; | 124 | )?; |
| 125 | p.expect("list: connecting...\r\n\r\r\r")?; | 125 | p.expect("list: connecting...\r\n\r\r\r")?; |
| 126 | // println!("{}", p.expect_eventually("\r\n\r\n")?); | 126 | // println!("{}", p.expect_eventually("\r\n\r\n")?); |
| @@ -135,8 +135,8 @@ mod with_state_announcement { | |||
| 135 | .collect::<HashSet<String>>(), | 135 | .collect::<HashSet<String>>(), |
| 136 | HashSet::from([ | 136 | HashSet::from([ |
| 137 | "@refs/heads/main HEAD".to_string(), | 137 | "@refs/heads/main HEAD".to_string(), |
| 138 | format!("{} refs/heads/main", main_commit_id), | 138 | format!("{main_commit_id} refs/heads/main"), |
| 139 | format!("{} refs/heads/example-branch", example_commit_id), | 139 | format!("{example_commit_id} refs/heads/example-branch"), |
| 140 | ]), | 140 | ]), |
| 141 | ); | 141 | ); |
| 142 | 142 | ||
| @@ -204,13 +204,12 @@ mod with_state_announcement { | |||
| 204 | let mut p = cli_tester_after_fetch(&git_repo)?; | 204 | let mut p = cli_tester_after_fetch(&git_repo)?; |
| 205 | p.send_line("list")?; | 205 | p.send_line("list")?; |
| 206 | p.expect( | 206 | p.expect( |
| 207 | format!("fetching {} ref list over filesystem...\r\n", source_path).as_str(), | 207 | format!("fetching {source_path} ref list over filesystem...\r\n").as_str(), |
| 208 | )?; | 208 | )?; |
| 209 | p.expect("list: connecting...\r\n\r\r\r")?; | 209 | p.expect("list: connecting...\r\n\r\r\r")?; |
| 210 | p.expect( | 210 | p.expect( |
| 211 | format!( | 211 | format!( |
| 212 | "WARNING: {} refs/heads/main is out of sync with nostr \r\n", | 212 | "WARNING: {source_path} refs/heads/main is out of sync with nostr \r\n" |
| 213 | source_path | ||
| 214 | ) | 213 | ) |
| 215 | .as_str(), | 214 | .as_str(), |
| 216 | )?; | 215 | )?; |
| @@ -231,8 +230,8 @@ mod with_state_announcement { | |||
| 231 | .collect::<HashSet<String>>(), | 230 | .collect::<HashSet<String>>(), |
| 232 | HashSet::from([ | 231 | HashSet::from([ |
| 233 | "@refs/heads/main HEAD".to_string(), | 232 | "@refs/heads/main HEAD".to_string(), |
| 234 | format!("{} refs/heads/main", main_original_commit_id), | 233 | format!("{main_original_commit_id} refs/heads/main"), |
| 235 | format!("{} refs/heads/example-branch", example_commit_id), | 234 | format!("{example_commit_id} refs/heads/example-branch"), |
| 236 | ]), | 235 | ]), |
| 237 | ); | 236 | ); |
| 238 | Ok(()) | 237 | Ok(()) |
| @@ -292,7 +291,7 @@ mod with_state_announcement { | |||
| 292 | let mut p = cli_tester_after_fetch(&git_repo)?; | 291 | let mut p = cli_tester_after_fetch(&git_repo)?; |
| 293 | p.send_line("list")?; | 292 | p.send_line("list")?; |
| 294 | p.expect( | 293 | p.expect( |
| 295 | format!("fetching {} ref list over filesystem...\r\n", source_path).as_str(), | 294 | format!("fetching {source_path} ref list over filesystem...\r\n").as_str(), |
| 296 | )?; | 295 | )?; |
| 297 | p.expect("list: connecting...\r\n\r\r\r")?; | 296 | p.expect("list: connecting...\r\n\r\r\r")?; |
| 298 | // println!("{}", p.expect_eventually("\r\n\r\n")?); | 297 | // println!("{}", p.expect_eventually("\r\n\r\n")?); |
diff --git a/tests/git_remote_nostr/push.rs b/tests/git_remote_nostr/push.rs index f46b0ea..5912543 100644 --- a/tests/git_remote_nostr/push.rs +++ b/tests/git_remote_nostr/push.rs | |||
| @@ -969,19 +969,17 @@ async fn proposal_three_way_merge_commit_pushed_to_main_leads_to_status_event_is | |||
| 969 | std::fs::write(git_repo.dir.join("new.md"), "some content")?; | 969 | std::fs::write(git_repo.dir.join("new.md"), "some content")?; |
| 970 | git_repo.stage_and_commit("new.md")?; | 970 | git_repo.stage_and_commit("new.md")?; |
| 971 | 971 | ||
| 972 | CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, [ | 972 | CliTester::new_git_with_remote_helper_from_dir( |
| 973 | "merge", | 973 | &git_repo.dir, |
| 974 | &branch_name, | 974 | ["merge", &branch_name, "-m", "proposal merge commit message"], |
| 975 | "-m", | 975 | ) |
| 976 | "proposal merge commit message", | ||
| 977 | ]) | ||
| 978 | .expect_end_eventually_and_print()?; | 976 | .expect_end_eventually_and_print()?; |
| 979 | 977 | ||
| 980 | let oid = git_repo.get_tip_of_local_branch("main")?; | 978 | let oid = git_repo.get_tip_of_local_branch("main")?; |
| 981 | 979 | ||
| 982 | let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); | 980 | let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); |
| 983 | cli_expect_nostr_fetch(&mut p)?; | 981 | cli_expect_nostr_fetch(&mut p)?; |
| 984 | p.expect(format!("fetching {} ref list over filesystem...\r\n", source_path).as_str())?; | 982 | p.expect(format!("fetching {source_path} ref list over filesystem...\r\n").as_str())?; |
| 985 | p.expect("list: connecting...\r\n")?; | 983 | p.expect("list: connecting...\r\n")?; |
| 986 | p.expect_eventually("merge commit ")?; | 984 | p.expect_eventually("merge commit ")?; |
| 987 | // shorthand merge commit id appears in this gap | 985 | // shorthand merge commit id appears in this gap |
| @@ -1125,19 +1123,17 @@ async fn proposal_fast_forward_merge_commits_pushed_to_main_leads_to_status_even | |||
| 1125 | git_repo.checkout_remote_branch(&branch_name)?; | 1123 | git_repo.checkout_remote_branch(&branch_name)?; |
| 1126 | git_repo.checkout("refs/heads/main")?; | 1124 | git_repo.checkout("refs/heads/main")?; |
| 1127 | 1125 | ||
| 1128 | CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, [ | 1126 | CliTester::new_git_with_remote_helper_from_dir( |
| 1129 | "merge", | 1127 | &git_repo.dir, |
| 1130 | &branch_name, | 1128 | ["merge", &branch_name, "-m", "proposal merge commit message"], |
| 1131 | "-m", | 1129 | ) |
| 1132 | "proposal merge commit message", | ||
| 1133 | ]) | ||
| 1134 | .expect_end_eventually_and_print()?; | 1130 | .expect_end_eventually_and_print()?; |
| 1135 | 1131 | ||
| 1136 | let oid = git_repo.get_tip_of_local_branch("main")?; | 1132 | let oid = git_repo.get_tip_of_local_branch("main")?; |
| 1137 | 1133 | ||
| 1138 | let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); | 1134 | let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); |
| 1139 | cli_expect_nostr_fetch(&mut p)?; | 1135 | cli_expect_nostr_fetch(&mut p)?; |
| 1140 | p.expect(format!("fetching {} ref list over filesystem...\r\n", source_path).as_str())?; | 1136 | p.expect(format!("fetching {source_path} ref list over filesystem...\r\n").as_str())?; |
| 1141 | p.expect("list: connecting...\r\n")?; | 1137 | p.expect("list: connecting...\r\n")?; |
| 1142 | p.expect_eventually(format!( | 1138 | p.expect_eventually(format!( |
| 1143 | "fast-forward merge: create nostr proposal status event for {branch_name}\r\n" | 1139 | "fast-forward merge: create nostr proposal status event for {branch_name}\r\n" |
| @@ -1323,7 +1319,7 @@ async fn proposal_commits_applied_and_pushed_to_main_leads_to_status_event_issue | |||
| 1323 | 1319 | ||
| 1324 | let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); | 1320 | let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); |
| 1325 | cli_expect_nostr_fetch(&mut p)?; | 1321 | cli_expect_nostr_fetch(&mut p)?; |
| 1326 | p.expect(format!("fetching {} ref list over filesystem...\r\n", source_path).as_str())?; | 1322 | p.expect(format!("fetching {source_path} ref list over filesystem...\r\n").as_str())?; |
| 1327 | p.expect("list: connecting...\r\n")?; | 1323 | p.expect("list: connecting...\r\n")?; |
| 1328 | p.expect_eventually(format!( | 1324 | p.expect_eventually(format!( |
| 1329 | "applied commits from proposal: create nostr proposal status event for {branch_name}\r\n" ))?; | 1325 | "applied commits from proposal: create nostr proposal status event for {branch_name}\r\n" ))?; |
| @@ -1484,7 +1480,7 @@ async fn push_2_commits_to_existing_proposal() -> Result<()> { | |||
| 1484 | 1480 | ||
| 1485 | let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); | 1481 | let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push"]); |
| 1486 | cli_expect_nostr_fetch(&mut p)?; | 1482 | cli_expect_nostr_fetch(&mut p)?; |
| 1487 | p.expect(format!("fetching {} ref list over filesystem...\r\n", source_path).as_str())?; | 1483 | p.expect(format!("fetching {source_path} ref list over filesystem...\r\n").as_str())?; |
| 1488 | p.expect("list: connecting...\r\n\r\r\r")?; | 1484 | p.expect("list: connecting...\r\n\r\r\r")?; |
| 1489 | p.expect_eventually_and_print(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; | 1485 | p.expect_eventually_and_print(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; |
| 1490 | let output = p.expect_end_eventually()?; | 1486 | let output = p.expect_end_eventually()?; |
| @@ -1639,7 +1635,7 @@ async fn force_push_creates_proposal_revision() -> Result<()> { | |||
| 1639 | let mut p = | 1635 | let mut p = |
| 1640 | CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push", "--force"]); | 1636 | CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, ["push", "--force"]); |
| 1641 | cli_expect_nostr_fetch(&mut p)?; | 1637 | cli_expect_nostr_fetch(&mut p)?; |
| 1642 | p.expect(format!("fetching {} ref list over filesystem...\r\n", source_path).as_str())?; | 1638 | p.expect(format!("fetching {source_path} ref list over filesystem...\r\n").as_str())?; |
| 1643 | p.expect("list: connecting...\r\n")?; | 1639 | p.expect("list: connecting...\r\n")?; |
| 1644 | p.expect_eventually_and_print(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; | 1640 | p.expect_eventually_and_print(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; |
| 1645 | let output = p.expect_end_eventually()?; | 1641 | let output = p.expect_end_eventually()?; |
| @@ -1784,14 +1780,12 @@ async fn push_new_pr_branch_creates_proposal() -> Result<()> { | |||
| 1784 | std::fs::write(git_repo.dir.join("new2.md"), "some content")?; | 1780 | std::fs::write(git_repo.dir.join("new2.md"), "some content")?; |
| 1785 | git_repo.stage_and_commit("new2.md")?; | 1781 | git_repo.stage_and_commit("new2.md")?; |
| 1786 | 1782 | ||
| 1787 | let mut p = CliTester::new_git_with_remote_helper_from_dir(&git_repo.dir, [ | 1783 | let mut p = CliTester::new_git_with_remote_helper_from_dir( |
| 1788 | "push", | 1784 | &git_repo.dir, |
| 1789 | "-u", | 1785 | ["push", "-u", "origin", branch_name], |
| 1790 | "origin", | 1786 | ); |
| 1791 | branch_name, | ||
| 1792 | ]); | ||
| 1793 | cli_expect_nostr_fetch(&mut p)?; | 1787 | cli_expect_nostr_fetch(&mut p)?; |
| 1794 | p.expect(format!("fetching {} ref list over filesystem...\r\n", source_path).as_str())?; | 1788 | p.expect(format!("fetching {source_path} ref list over filesystem...\r\n").as_str())?; |
| 1795 | p.expect("list: connecting...\r\n\r\r\r")?; | 1789 | p.expect("list: connecting...\r\n\r\r\r")?; |
| 1796 | p.expect_eventually_and_print(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; | 1790 | p.expect_eventually_and_print(format!("To {}\r\n", get_nostr_remote_url()?).as_str())?; |
| 1797 | let output = p.expect_end_eventually()?; | 1791 | let output = p.expect_end_eventually()?; |
diff --git a/tests/ngit_init.rs b/tests/ngit_init.rs index e49dbdd..1a23177 100644 --- a/tests/ngit_init.rs +++ b/tests/ngit_init.rs | |||
| @@ -75,10 +75,14 @@ mod when_repo_not_previously_claimed { | |||
| 75 | 8051, | 75 | 8051, |
| 76 | None, | 76 | None, |
| 77 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 77 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 78 | relay.respond_events(client_id, &subscription_id, &vec![ | 78 | relay.respond_events( |
| 79 | generate_test_key_1_metadata_event("fred"), | 79 | client_id, |
| 80 | generate_test_key_1_relay_list_event(), | 80 | &subscription_id, |
| 81 | ])?; | 81 | &vec![ |
| 82 | generate_test_key_1_metadata_event("fred"), | ||
| 83 | generate_test_key_1_relay_list_event(), | ||
| 84 | ], | ||
| 85 | )?; | ||
| 82 | Ok(()) | 86 | Ok(()) |
| 83 | }), | 87 | }), |
| 84 | ), | 88 | ), |
| @@ -197,10 +201,14 @@ mod when_repo_not_previously_claimed { | |||
| 197 | 8051, | 201 | 8051, |
| 198 | None, | 202 | None, |
| 199 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 203 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 200 | relay.respond_events(client_id, &subscription_id, &vec![ | 204 | relay.respond_events( |
| 201 | generate_test_key_1_metadata_event("fred"), | 205 | client_id, |
| 202 | generate_test_key_1_relay_list_event(), | 206 | &subscription_id, |
| 203 | ])?; | 207 | &vec![ |
| 208 | generate_test_key_1_metadata_event("fred"), | ||
| 209 | generate_test_key_1_relay_list_event(), | ||
| 210 | ], | ||
| 211 | )?; | ||
| 204 | Ok(()) | 212 | Ok(()) |
| 205 | }), | 213 | }), |
| 206 | ), | 214 | ), |
| @@ -454,10 +462,14 @@ mod when_repo_not_previously_claimed { | |||
| 454 | 8051, | 462 | 8051, |
| 455 | None, | 463 | None, |
| 456 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 464 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 457 | relay.respond_events(client_id, &subscription_id, &vec![ | 465 | relay.respond_events( |
| 458 | generate_test_key_1_metadata_event("fred"), | 466 | client_id, |
| 459 | generate_test_key_1_relay_list_event(), | 467 | &subscription_id, |
| 460 | ])?; | 468 | &vec![ |
| 469 | generate_test_key_1_metadata_event("fred"), | ||
| 470 | generate_test_key_1_relay_list_event(), | ||
| 471 | ], | ||
| 472 | )?; | ||
| 461 | Ok(()) | 473 | Ok(()) |
| 462 | }), | 474 | }), |
| 463 | ), | 475 | ), |
diff --git a/tests/ngit_list.rs b/tests/ngit_list.rs index bb742cf..0547ad4 100644 --- a/tests/ngit_list.rs +++ b/tests/ngit_list.rs | |||
| @@ -201,11 +201,14 @@ mod when_main_branch_is_uptodate { | |||
| 201 | 201 | ||
| 202 | p.expect("fetching updates...\r\n")?; | 202 | p.expect("fetching updates...\r\n")?; |
| 203 | p.expect_eventually("\r\n")?; // some updates listed here | 203 | p.expect_eventually("\r\n")?; // some updates listed here |
| 204 | let mut c = p.expect_choice("all proposals", vec![ | 204 | let mut c = p.expect_choice( |
| 205 | format!("\"{PROPOSAL_TITLE_3}\""), | 205 | "all proposals", |
| 206 | format!("\"{PROPOSAL_TITLE_2}\""), | 206 | vec![ |
| 207 | format!("\"{PROPOSAL_TITLE_1}\""), | 207 | format!("\"{PROPOSAL_TITLE_3}\""), |
| 208 | ])?; | 208 | format!("\"{PROPOSAL_TITLE_2}\""), |
| 209 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 210 | ], | ||
| 211 | )?; | ||
| 209 | c.succeeds_with(2, true, None)?; | 212 | c.succeeds_with(2, true, None)?; |
| 210 | let mut c = p.expect_choice("", vec![ | 213 | let mut c = p.expect_choice("", vec![ |
| 211 | format!( | 214 | format!( |
| @@ -217,8 +220,7 @@ mod when_main_branch_is_uptodate { | |||
| 217 | ])?; | 220 | ])?; |
| 218 | c.succeeds_with(0, true, None)?; | 221 | c.succeeds_with(0, true, None)?; |
| 219 | p.expect(format!( | 222 | p.expect(format!( |
| 220 | "checked out proposal as 'pr/{}(", | 223 | "checked out proposal as 'pr/{FEATURE_BRANCH_NAME_1}(", |
| 221 | FEATURE_BRANCH_NAME_1, | ||
| 222 | ))?; | 224 | ))?; |
| 223 | p.expect_end_eventually_with(")' branch\r\n")?; | 225 | p.expect_end_eventually_with(")' branch\r\n")?; |
| 224 | 226 | ||
| @@ -318,11 +320,14 @@ mod when_main_branch_is_uptodate { | |||
| 318 | 320 | ||
| 319 | p.expect("fetching updates...\r\n")?; | 321 | p.expect("fetching updates...\r\n")?; |
| 320 | p.expect_eventually("\r\n")?; // some updates listed here | 322 | p.expect_eventually("\r\n")?; // some updates listed here |
| 321 | let mut c = p.expect_choice("all proposals", vec![ | 323 | let mut c = p.expect_choice( |
| 322 | format!("\"{PROPOSAL_TITLE_3}\""), | 324 | "all proposals", |
| 323 | format!("\"{PROPOSAL_TITLE_2}\""), | 325 | vec![ |
| 324 | format!("\"{PROPOSAL_TITLE_1}\""), | 326 | format!("\"{PROPOSAL_TITLE_3}\""), |
| 325 | ])?; | 327 | format!("\"{PROPOSAL_TITLE_2}\""), |
| 328 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 329 | ], | ||
| 330 | )?; | ||
| 326 | c.succeeds_with(0, true, None)?; | 331 | c.succeeds_with(0, true, None)?; |
| 327 | let mut c = p.expect_choice("", vec![ | 332 | let mut c = p.expect_choice("", vec![ |
| 328 | format!( | 333 | format!( |
| @@ -334,8 +339,7 @@ mod when_main_branch_is_uptodate { | |||
| 334 | ])?; | 339 | ])?; |
| 335 | c.succeeds_with(0, true, Some(0))?; | 340 | c.succeeds_with(0, true, Some(0))?; |
| 336 | p.expect(format!( | 341 | p.expect(format!( |
| 337 | "checked out proposal as 'pr/{}(", | 342 | "checked out proposal as 'pr/{FEATURE_BRANCH_NAME_3}(", |
| 338 | FEATURE_BRANCH_NAME_3, | ||
| 339 | ))?; | 343 | ))?; |
| 340 | p.expect_end_eventually_with(")' branch\r\n")?; | 344 | p.expect_end_eventually_with(")' branch\r\n")?; |
| 341 | 345 | ||
| @@ -438,12 +442,15 @@ mod when_main_branch_is_uptodate { | |||
| 438 | 442 | ||
| 439 | p.expect("fetching updates...\r\n")?; | 443 | p.expect("fetching updates...\r\n")?; |
| 440 | p.expect_eventually("\r\n")?; // some updates listed here | 444 | p.expect_eventually("\r\n")?; // some updates listed here |
| 441 | let mut c = p.expect_choice("all proposals", vec![ | 445 | let mut c = p.expect_choice( |
| 442 | format!("add d3.md"), // commit msg title | 446 | "all proposals", |
| 443 | format!("\"{PROPOSAL_TITLE_3}\""), | 447 | vec![ |
| 444 | format!("\"{PROPOSAL_TITLE_2}\""), | 448 | format!("add d3.md"), // commit msg title |
| 445 | format!("\"{PROPOSAL_TITLE_1}\""), | 449 | format!("\"{PROPOSAL_TITLE_3}\""), |
| 446 | ])?; | 450 | format!("\"{PROPOSAL_TITLE_2}\""), |
| 451 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 452 | ], | ||
| 453 | )?; | ||
| 447 | c.succeeds_with(0, true, None)?; | 454 | c.succeeds_with(0, true, None)?; |
| 448 | let mut c = p.expect_choice("", vec![ | 455 | let mut c = p.expect_choice("", vec![ |
| 449 | format!( | 456 | format!( |
| @@ -513,12 +520,15 @@ mod when_main_branch_is_uptodate { | |||
| 513 | 520 | ||
| 514 | p.expect("fetching updates...\r\n")?; | 521 | p.expect("fetching updates...\r\n")?; |
| 515 | p.expect_eventually("\r\n")?; // some updates listed here | 522 | p.expect_eventually("\r\n")?; // some updates listed here |
| 516 | let mut c = p.expect_choice("all proposals", vec![ | 523 | let mut c = p.expect_choice( |
| 517 | format!("add d3.md"), // commit msg title | 524 | "all proposals", |
| 518 | format!("\"{PROPOSAL_TITLE_3}\""), | 525 | vec![ |
| 519 | format!("\"{PROPOSAL_TITLE_2}\""), | 526 | format!("add d3.md"), // commit msg title |
| 520 | format!("\"{PROPOSAL_TITLE_1}\""), | 527 | format!("\"{PROPOSAL_TITLE_3}\""), |
| 521 | ])?; | 528 | format!("\"{PROPOSAL_TITLE_2}\""), |
| 529 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 530 | ], | ||
| 531 | )?; | ||
| 522 | c.succeeds_with(0, true, None)?; | 532 | c.succeeds_with(0, true, None)?; |
| 523 | let mut c = p.expect_choice("", vec![ | 533 | let mut c = p.expect_choice("", vec![ |
| 524 | format!( | 534 | format!( |
| @@ -530,8 +540,7 @@ mod when_main_branch_is_uptodate { | |||
| 530 | ])?; | 540 | ])?; |
| 531 | c.succeeds_with(0, true, Some(0))?; | 541 | c.succeeds_with(0, true, Some(0))?; |
| 532 | p.expect(format!( | 542 | p.expect(format!( |
| 533 | "checked out proposal as 'pr/{}(", | 543 | "checked out proposal as 'pr/{FEATURE_BRANCH_NAME_4}(", |
| 534 | FEATURE_BRANCH_NAME_4, | ||
| 535 | ))?; | 544 | ))?; |
| 536 | p.expect_end_eventually_with(")' branch\r\n")?; | 545 | p.expect_end_eventually_with(")' branch\r\n")?; |
| 537 | 546 | ||
| @@ -633,11 +642,14 @@ mod when_main_branch_is_uptodate { | |||
| 633 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | 642 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 634 | p.expect("fetching updates...\r\n")?; | 643 | p.expect("fetching updates...\r\n")?; |
| 635 | p.expect_eventually("\r\n")?; // some updates listed here | 644 | p.expect_eventually("\r\n")?; // some updates listed here |
| 636 | let mut c = p.expect_choice("all proposals", vec![ | 645 | let mut c = p.expect_choice( |
| 637 | format!("\"{PROPOSAL_TITLE_3}\""), | 646 | "all proposals", |
| 638 | format!("\"{PROPOSAL_TITLE_2}\""), | 647 | vec![ |
| 639 | format!("\"{PROPOSAL_TITLE_1}\""), | 648 | format!("\"{PROPOSAL_TITLE_3}\""), |
| 640 | ])?; | 649 | format!("\"{PROPOSAL_TITLE_2}\""), |
| 650 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 651 | ], | ||
| 652 | )?; | ||
| 641 | c.succeeds_with(2, true, None)?; | 653 | c.succeeds_with(2, true, None)?; |
| 642 | let mut c = p.expect_choice("", vec![ | 654 | let mut c = p.expect_choice("", vec![ |
| 643 | format!( | 655 | format!( |
| @@ -655,18 +667,24 @@ mod when_main_branch_is_uptodate { | |||
| 655 | p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | 667 | p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 656 | p.expect("fetching updates...\r\n")?; | 668 | p.expect("fetching updates...\r\n")?; |
| 657 | p.expect_eventually("\r\n")?; // some updates listed here | 669 | p.expect_eventually("\r\n")?; // some updates listed here |
| 658 | let mut c = p.expect_choice("all proposals", vec![ | 670 | let mut c = p.expect_choice( |
| 659 | format!("\"{PROPOSAL_TITLE_3}\""), | 671 | "all proposals", |
| 660 | format!("\"{PROPOSAL_TITLE_2}\""), | 672 | vec![ |
| 661 | format!("\"{PROPOSAL_TITLE_1}\""), | 673 | format!("\"{PROPOSAL_TITLE_3}\""), |
| 662 | ])?; | 674 | format!("\"{PROPOSAL_TITLE_2}\""), |
| 675 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 676 | ], | ||
| 677 | )?; | ||
| 663 | c.succeeds_with(2, true, None)?; | 678 | c.succeeds_with(2, true, None)?; |
| 664 | let mut c = p.expect_choice("", vec![ | 679 | let mut c = p.expect_choice( |
| 665 | format!("checkout proposal branch (2 ahead 0 behind 'main')"), | 680 | "", |
| 666 | format!("apply to current branch with `git am`"), | 681 | vec![ |
| 667 | format!("download to ./patches"), | 682 | format!("checkout proposal branch (2 ahead 0 behind 'main')"), |
| 668 | format!("back"), | 683 | format!("apply to current branch with `git am`"), |
| 669 | ])?; | 684 | format!("download to ./patches"), |
| 685 | format!("back"), | ||
| 686 | ], | ||
| 687 | )?; | ||
| 670 | c.succeeds_with(0, true, Some(0))?; | 688 | c.succeeds_with(0, true, Some(0))?; |
| 671 | p.expect_end_eventually_and_print()?; | 689 | p.expect_end_eventually_and_print()?; |
| 672 | 690 | ||
| @@ -720,11 +738,14 @@ mod when_main_branch_is_uptodate { | |||
| 720 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | 738 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 721 | p.expect("fetching updates...\r\n")?; | 739 | p.expect("fetching updates...\r\n")?; |
| 722 | p.expect_eventually("\r\n")?; // some updates listed here | 740 | p.expect_eventually("\r\n")?; // some updates listed here |
| 723 | let mut c = p.expect_choice("all proposals", vec![ | 741 | let mut c = p.expect_choice( |
| 724 | format!("\"{PROPOSAL_TITLE_3}\""), | 742 | "all proposals", |
| 725 | format!("\"{PROPOSAL_TITLE_2}\""), | 743 | vec![ |
| 726 | format!("\"{PROPOSAL_TITLE_1}\""), | 744 | format!("\"{PROPOSAL_TITLE_3}\""), |
| 727 | ])?; | 745 | format!("\"{PROPOSAL_TITLE_2}\""), |
| 746 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 747 | ], | ||
| 748 | )?; | ||
| 728 | c.succeeds_with(2, true, None)?; | 749 | c.succeeds_with(2, true, None)?; |
| 729 | let mut c = p.expect_choice("", vec![ | 750 | let mut c = p.expect_choice("", vec![ |
| 730 | format!( | 751 | format!( |
| @@ -742,22 +763,27 @@ mod when_main_branch_is_uptodate { | |||
| 742 | p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | 763 | p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 743 | p.expect("fetching updates...\r\n")?; | 764 | p.expect("fetching updates...\r\n")?; |
| 744 | p.expect_eventually("\r\n")?; // some updates listed here | 765 | p.expect_eventually("\r\n")?; // some updates listed here |
| 745 | let mut c = p.expect_choice("all proposals", vec![ | 766 | let mut c = p.expect_choice( |
| 746 | format!("\"{PROPOSAL_TITLE_3}\""), | 767 | "all proposals", |
| 747 | format!("\"{PROPOSAL_TITLE_2}\""), | 768 | vec![ |
| 748 | format!("\"{PROPOSAL_TITLE_1}\""), | 769 | format!("\"{PROPOSAL_TITLE_3}\""), |
| 749 | ])?; | 770 | format!("\"{PROPOSAL_TITLE_2}\""), |
| 771 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 772 | ], | ||
| 773 | )?; | ||
| 750 | c.succeeds_with(2, true, None)?; | 774 | c.succeeds_with(2, true, None)?; |
| 751 | let mut c = p.expect_choice("", vec![ | 775 | let mut c = p.expect_choice( |
| 752 | format!("checkout proposal branch (2 ahead 0 behind 'main')"), | 776 | "", |
| 753 | format!("apply to current branch with `git am`"), | 777 | vec![ |
| 754 | format!("download to ./patches"), | 778 | format!("checkout proposal branch (2 ahead 0 behind 'main')"), |
| 755 | format!("back"), | 779 | format!("apply to current branch with `git am`"), |
| 756 | ])?; | 780 | format!("download to ./patches"), |
| 781 | format!("back"), | ||
| 782 | ], | ||
| 783 | )?; | ||
| 757 | c.succeeds_with(0, true, Some(0))?; | 784 | c.succeeds_with(0, true, Some(0))?; |
| 758 | p.expect(format!( | 785 | p.expect(format!( |
| 759 | "checked out proposal as 'pr/{}(", | 786 | "checked out proposal as 'pr/{FEATURE_BRANCH_NAME_1}(", |
| 760 | FEATURE_BRANCH_NAME_1, | ||
| 761 | ))?; | 787 | ))?; |
| 762 | p.expect_end_eventually_with(")' branch\r\n")?; | 788 | p.expect_end_eventually_with(")' branch\r\n")?; |
| 763 | 789 | ||
| @@ -827,18 +853,24 @@ mod when_main_branch_is_uptodate { | |||
| 827 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | 853 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 828 | p.expect("fetching updates...\r\n")?; | 854 | p.expect("fetching updates...\r\n")?; |
| 829 | p.expect_eventually("\r\n")?; // some updates listed here | 855 | p.expect_eventually("\r\n")?; // some updates listed here |
| 830 | let mut c = p.expect_choice("all proposals", vec![ | 856 | let mut c = p.expect_choice( |
| 831 | format!("\"{PROPOSAL_TITLE_3}\""), | 857 | "all proposals", |
| 832 | format!("\"{PROPOSAL_TITLE_2}\""), | 858 | vec![ |
| 833 | format!("\"{PROPOSAL_TITLE_1}\""), | 859 | format!("\"{PROPOSAL_TITLE_3}\""), |
| 834 | ])?; | 860 | format!("\"{PROPOSAL_TITLE_2}\""), |
| 861 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 862 | ], | ||
| 863 | )?; | ||
| 835 | c.succeeds_with(2, true, None)?; | 864 | c.succeeds_with(2, true, None)?; |
| 836 | let mut c = p.expect_choice("", vec![ | 865 | let mut c = p.expect_choice( |
| 837 | format!("checkout proposal branch and apply 1 appendments"), | 866 | "", |
| 838 | format!("apply to current branch with `git am`"), | 867 | vec![ |
| 839 | format!("download to ./patches"), | 868 | format!("checkout proposal branch and apply 1 appendments"), |
| 840 | format!("back"), | 869 | format!("apply to current branch with `git am`"), |
| 841 | ])?; | 870 | format!("download to ./patches"), |
| 871 | format!("back"), | ||
| 872 | ], | ||
| 873 | )?; | ||
| 842 | c.succeeds_with(0, true, Some(0))?; | 874 | c.succeeds_with(0, true, Some(0))?; |
| 843 | p.expect("checked out proposal branch and applied 1 appendments (2 ahead 0 behind 'main')\r\n")?; | 875 | p.expect("checked out proposal branch and applied 1 appendments (2 ahead 0 behind 'main')\r\n")?; |
| 844 | p.expect_end()?; | 876 | p.expect_end()?; |
| @@ -897,18 +929,24 @@ mod when_main_branch_is_uptodate { | |||
| 897 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | 929 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 898 | p.expect("fetching updates...\r\n")?; | 930 | p.expect("fetching updates...\r\n")?; |
| 899 | p.expect_eventually("\r\n")?; // some updates listed here | 931 | p.expect_eventually("\r\n")?; // some updates listed here |
| 900 | let mut c = p.expect_choice("all proposals", vec![ | 932 | let mut c = p.expect_choice( |
| 901 | format!("\"{PROPOSAL_TITLE_3}\""), | 933 | "all proposals", |
| 902 | format!("\"{PROPOSAL_TITLE_2}\""), | 934 | vec![ |
| 903 | format!("\"{PROPOSAL_TITLE_1}\""), | 935 | format!("\"{PROPOSAL_TITLE_3}\""), |
| 904 | ])?; | 936 | format!("\"{PROPOSAL_TITLE_2}\""), |
| 937 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 938 | ], | ||
| 939 | )?; | ||
| 905 | c.succeeds_with(2, true, None)?; | 940 | c.succeeds_with(2, true, None)?; |
| 906 | let mut c = p.expect_choice("", vec![ | 941 | let mut c = p.expect_choice( |
| 907 | format!("checkout proposal branch and apply 1 appendments"), | 942 | "", |
| 908 | format!("apply to current branch with `git am`"), | 943 | vec![ |
| 909 | format!("download to ./patches"), | 944 | format!("checkout proposal branch and apply 1 appendments"), |
| 910 | format!("back"), | 945 | format!("apply to current branch with `git am`"), |
| 911 | ])?; | 946 | format!("download to ./patches"), |
| 947 | format!("back"), | ||
| 948 | ], | ||
| 949 | )?; | ||
| 912 | c.succeeds_with(0, true, Some(0))?; | 950 | c.succeeds_with(0, true, Some(0))?; |
| 913 | p.expect("checked out proposal branch and applied 1 appendments (2 ahead 0 behind 'main')\r\n")?; | 951 | p.expect("checked out proposal branch and applied 1 appendments (2 ahead 0 behind 'main')\r\n")?; |
| 914 | p.expect_end()?; | 952 | p.expect_end()?; |
| @@ -1004,21 +1042,29 @@ mod when_main_branch_is_uptodate { | |||
| 1004 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | 1042 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 1005 | p.expect("fetching updates...\r\n")?; | 1043 | p.expect("fetching updates...\r\n")?; |
| 1006 | p.expect_eventually("\r\n")?; // some updates listed here | 1044 | p.expect_eventually("\r\n")?; // some updates listed here |
| 1007 | let mut c = p.expect_choice("all proposals", vec![ | 1045 | let mut c = p.expect_choice( |
| 1008 | format!("\"{PROPOSAL_TITLE_3}\""), | 1046 | "all proposals", |
| 1009 | format!("\"{PROPOSAL_TITLE_2}\""), | 1047 | vec![ |
| 1010 | format!("\"{PROPOSAL_TITLE_1}\""), | 1048 | format!("\"{PROPOSAL_TITLE_3}\""), |
| 1011 | ])?; | 1049 | format!("\"{PROPOSAL_TITLE_2}\""), |
| 1050 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 1051 | ], | ||
| 1052 | )?; | ||
| 1012 | c.succeeds_with(2, true, None)?; | 1053 | c.succeeds_with(2, true, None)?; |
| 1013 | p.expect_eventually("--force`\r\n")?; | 1054 | p.expect_eventually("--force`\r\n")?; |
| 1014 | 1055 | ||
| 1015 | let mut c = p.expect_choice("", vec![ | 1056 | let mut c = p.expect_choice( |
| 1016 | format!("checkout local branch with unpublished changes"), | 1057 | "", |
| 1017 | format!("discard unpublished changes and checkout new revision"), | 1058 | vec![ |
| 1018 | format!("apply to current branch with `git am`"), | 1059 | format!("checkout local branch with unpublished changes"), |
| 1019 | format!("download to ./patches"), | 1060 | format!( |
| 1020 | "back".to_string(), | 1061 | "discard unpublished changes and checkout new revision" |
| 1021 | ])?; | 1062 | ), |
| 1063 | format!("apply to current branch with `git am`"), | ||
| 1064 | format!("download to ./patches"), | ||
| 1065 | "back".to_string(), | ||
| 1066 | ], | ||
| 1067 | )?; | ||
| 1022 | c.succeeds_with(1, true, Some(0))?; | 1068 | c.succeeds_with(1, true, Some(0))?; |
| 1023 | 1069 | ||
| 1024 | p.expect_end_eventually_and_print()?; | 1070 | p.expect_end_eventually_and_print()?; |
| @@ -1075,11 +1121,14 @@ mod when_main_branch_is_uptodate { | |||
| 1075 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | 1121 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 1076 | p.expect("fetching updates...\r\n")?; | 1122 | p.expect("fetching updates...\r\n")?; |
| 1077 | p.expect_eventually("\r\n")?; // some updates listed here | 1123 | p.expect_eventually("\r\n")?; // some updates listed here |
| 1078 | let mut c = p.expect_choice("all proposals", vec![ | 1124 | let mut c = p.expect_choice( |
| 1079 | format!("\"{PROPOSAL_TITLE_3}\""), | 1125 | "all proposals", |
| 1080 | format!("\"{PROPOSAL_TITLE_2}\""), | 1126 | vec![ |
| 1081 | format!("\"{PROPOSAL_TITLE_1}\""), | 1127 | format!("\"{PROPOSAL_TITLE_3}\""), |
| 1082 | ])?; | 1128 | format!("\"{PROPOSAL_TITLE_2}\""), |
| 1129 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 1130 | ], | ||
| 1131 | )?; | ||
| 1083 | c.succeeds_with(2, true, None)?; | 1132 | c.succeeds_with(2, true, None)?; |
| 1084 | p.expect("you have an amended/rebase version the proposal that is unpublished\r\n")?; | 1133 | p.expect("you have an amended/rebase version the proposal that is unpublished\r\n")?; |
| 1085 | p.expect("you have previously applied the latest version of the proposal (2 ahead 0 behind 'main') but your local proposal branch has amended or rebased it (2 ahead 0 behind 'main')\r\n")?; | 1134 | p.expect("you have previously applied the latest version of the proposal (2 ahead 0 behind 'main') but your local proposal branch has amended or rebased it (2 ahead 0 behind 'main')\r\n")?; |
| @@ -1088,13 +1137,18 @@ mod when_main_branch_is_uptodate { | |||
| 1088 | p.expect(" 2) run `ngit list` and checkout the latest published version of this proposal\r\n")?; | 1137 | p.expect(" 2) run `ngit list` and checkout the latest published version of this proposal\r\n")?; |
| 1089 | p.expect("if you are confident in your changes consider running `ngit push --force`\r\n")?; | 1138 | p.expect("if you are confident in your changes consider running `ngit push --force`\r\n")?; |
| 1090 | 1139 | ||
| 1091 | let mut c = p.expect_choice("", vec![ | 1140 | let mut c = p.expect_choice( |
| 1092 | format!("checkout local branch with unpublished changes"), | 1141 | "", |
| 1093 | format!("discard unpublished changes and checkout new revision"), | 1142 | vec![ |
| 1094 | format!("apply to current branch with `git am`"), | 1143 | format!("checkout local branch with unpublished changes"), |
| 1095 | format!("download to ./patches"), | 1144 | format!( |
| 1096 | "back".to_string(), | 1145 | "discard unpublished changes and checkout new revision" |
| 1097 | ])?; | 1146 | ), |
| 1147 | format!("apply to current branch with `git am`"), | ||
| 1148 | format!("download to ./patches"), | ||
| 1149 | "back".to_string(), | ||
| 1150 | ], | ||
| 1151 | )?; | ||
| 1098 | c.succeeds_with(1, true, Some(1))?; | 1152 | c.succeeds_with(1, true, Some(1))?; |
| 1099 | p.expect_end_with("checked out latest version of proposal (2 ahead 0 behind 'main'), replacing unpublished version (2 ahead 0 behind 'main')\r\n")?; | 1153 | p.expect_end_with("checked out latest version of proposal (2 ahead 0 behind 'main'), replacing unpublished version (2 ahead 0 behind 'main')\r\n")?; |
| 1100 | 1154 | ||
| @@ -1172,20 +1226,26 @@ mod when_main_branch_is_uptodate { | |||
| 1172 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | 1226 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 1173 | p.expect("fetching updates...\r\n")?; | 1227 | p.expect("fetching updates...\r\n")?; |
| 1174 | p.expect_eventually("\r\n")?; // some updates listed here | 1228 | p.expect_eventually("\r\n")?; // some updates listed here |
| 1175 | let mut c = p.expect_choice("all proposals", vec![ | 1229 | let mut c = p.expect_choice( |
| 1176 | format!("\"{PROPOSAL_TITLE_3}\""), | 1230 | "all proposals", |
| 1177 | format!("\"{PROPOSAL_TITLE_2}\""), | 1231 | vec![ |
| 1178 | format!("\"{PROPOSAL_TITLE_1}\""), | 1232 | format!("\"{PROPOSAL_TITLE_3}\""), |
| 1179 | ])?; | 1233 | format!("\"{PROPOSAL_TITLE_2}\""), |
| 1234 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 1235 | ], | ||
| 1236 | )?; | ||
| 1180 | c.succeeds_with(2, true, None)?; | 1237 | c.succeeds_with(2, true, None)?; |
| 1181 | p.expect( | 1238 | p.expect( |
| 1182 | "local proposal branch exists with 1 unpublished commits on top of the most up-to-date version of the proposal (3 ahead 0 behind 'main')\r\n", | 1239 | "local proposal branch exists with 1 unpublished commits on top of the most up-to-date version of the proposal (3 ahead 0 behind 'main')\r\n", |
| 1183 | )?; | 1240 | )?; |
| 1184 | 1241 | ||
| 1185 | let mut c = p.expect_choice("", vec![ | 1242 | let mut c = p.expect_choice( |
| 1186 | format!("checkout proposal branch with 1 unpublished commits"), | 1243 | "", |
| 1187 | format!("back"), | 1244 | vec![ |
| 1188 | ])?; | 1245 | format!("checkout proposal branch with 1 unpublished commits"), |
| 1246 | format!("back"), | ||
| 1247 | ], | ||
| 1248 | )?; | ||
| 1189 | c.succeeds_with(0, true, Some(0))?; | 1249 | c.succeeds_with(0, true, Some(0))?; |
| 1190 | p.expect("checked out proposal branch with 1 unpublished commits (3 ahead 0 behind 'main')\r\n")?; | 1250 | p.expect("checked out proposal branch with 1 unpublished commits (3 ahead 0 behind 'main')\r\n")?; |
| 1191 | p.expect_end()?; | 1251 | p.expect_end()?; |
| @@ -1248,20 +1308,26 @@ mod when_main_branch_is_uptodate { | |||
| 1248 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | 1308 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 1249 | p.expect("fetching updates...\r\n")?; | 1309 | p.expect("fetching updates...\r\n")?; |
| 1250 | p.expect_eventually("\r\n")?; // some updates listed here | 1310 | p.expect_eventually("\r\n")?; // some updates listed here |
| 1251 | let mut c = p.expect_choice("all proposals", vec![ | 1311 | let mut c = p.expect_choice( |
| 1252 | format!("\"{PROPOSAL_TITLE_3}\""), | 1312 | "all proposals", |
| 1253 | format!("\"{PROPOSAL_TITLE_2}\""), | 1313 | vec![ |
| 1254 | format!("\"{PROPOSAL_TITLE_1}\""), | 1314 | format!("\"{PROPOSAL_TITLE_3}\""), |
| 1255 | ])?; | 1315 | format!("\"{PROPOSAL_TITLE_2}\""), |
| 1316 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 1317 | ], | ||
| 1318 | )?; | ||
| 1256 | c.succeeds_with(2, true, None)?; | 1319 | c.succeeds_with(2, true, None)?; |
| 1257 | p.expect( | 1320 | p.expect( |
| 1258 | "local proposal branch exists with 1 unpublished commits on top of the most up-to-date version of the proposal (3 ahead 0 behind 'main')\r\n", | 1321 | "local proposal branch exists with 1 unpublished commits on top of the most up-to-date version of the proposal (3 ahead 0 behind 'main')\r\n", |
| 1259 | )?; | 1322 | )?; |
| 1260 | 1323 | ||
| 1261 | let mut c = p.expect_choice("", vec![ | 1324 | let mut c = p.expect_choice( |
| 1262 | format!("checkout proposal branch with 1 unpublished commits"), | 1325 | "", |
| 1263 | format!("back"), | 1326 | vec![ |
| 1264 | ])?; | 1327 | format!("checkout proposal branch with 1 unpublished commits"), |
| 1328 | format!("back"), | ||
| 1329 | ], | ||
| 1330 | )?; | ||
| 1265 | c.succeeds_with(0, true, Some(0))?; | 1331 | c.succeeds_with(0, true, Some(0))?; |
| 1266 | p.expect("checked out proposal branch with 1 unpublished commits (3 ahead 0 behind 'main')\r\n")?; | 1332 | p.expect("checked out proposal branch with 1 unpublished commits (3 ahead 0 behind 'main')\r\n")?; |
| 1267 | p.expect_end()?; | 1333 | p.expect_end()?; |
| @@ -1344,20 +1410,26 @@ mod when_main_branch_is_uptodate { | |||
| 1344 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | 1410 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 1345 | p.expect("fetching updates...\r\n")?; | 1411 | p.expect("fetching updates...\r\n")?; |
| 1346 | p.expect_eventually("\r\n")?; // some updates listed here | 1412 | p.expect_eventually("\r\n")?; // some updates listed here |
| 1347 | let mut c = p.expect_choice("all proposals", vec![ | 1413 | let mut c = p.expect_choice( |
| 1348 | format!("\"{PROPOSAL_TITLE_3}\""), | 1414 | "all proposals", |
| 1349 | format!("\"{PROPOSAL_TITLE_2}\""), | 1415 | vec![ |
| 1350 | format!("\"{PROPOSAL_TITLE_1}\""), | 1416 | format!("\"{PROPOSAL_TITLE_3}\""), |
| 1351 | ])?; | 1417 | format!("\"{PROPOSAL_TITLE_2}\""), |
| 1418 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 1419 | ], | ||
| 1420 | )?; | ||
| 1352 | c.succeeds_with(2, true, None)?; | 1421 | c.succeeds_with(2, true, None)?; |
| 1353 | p.expect("updated proposal available (2 ahead 0 behind 'main'). existing version is 2 ahead 1 behind 'main'\r\n")?; | 1422 | p.expect("updated proposal available (2 ahead 0 behind 'main'). existing version is 2 ahead 1 behind 'main'\r\n")?; |
| 1354 | let mut c = p.expect_choice("", vec![ | 1423 | let mut c = p.expect_choice( |
| 1355 | format!("checkout and overwrite existing proposal branch"), | 1424 | "", |
| 1356 | format!("checkout existing outdated proposal branch"), | 1425 | vec![ |
| 1357 | format!("apply to current branch with `git am`"), | 1426 | format!("checkout and overwrite existing proposal branch"), |
| 1358 | format!("download to ./patches"), | 1427 | format!("checkout existing outdated proposal branch"), |
| 1359 | format!("back"), | 1428 | format!("apply to current branch with `git am`"), |
| 1360 | ])?; | 1429 | format!("download to ./patches"), |
| 1430 | format!("back"), | ||
| 1431 | ], | ||
| 1432 | )?; | ||
| 1361 | c.succeeds_with(0, true, Some(0))?; | 1433 | c.succeeds_with(0, true, Some(0))?; |
| 1362 | p.expect("checked out new version of proposal (2 ahead 0 behind 'main'), replacing old version (2 ahead 1 behind 'main')\r\n")?; | 1434 | p.expect("checked out new version of proposal (2 ahead 0 behind 'main'), replacing old version (2 ahead 1 behind 'main')\r\n")?; |
| 1363 | p.expect_end()?; | 1435 | p.expect_end()?; |
| @@ -1411,20 +1483,26 @@ mod when_main_branch_is_uptodate { | |||
| 1411 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | 1483 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 1412 | p.expect("fetching updates...\r\n")?; | 1484 | p.expect("fetching updates...\r\n")?; |
| 1413 | p.expect_eventually("\r\n")?; // some updates listed here | 1485 | p.expect_eventually("\r\n")?; // some updates listed here |
| 1414 | let mut c = p.expect_choice("all proposals", vec![ | 1486 | let mut c = p.expect_choice( |
| 1415 | format!("\"{PROPOSAL_TITLE_3}\""), | 1487 | "all proposals", |
| 1416 | format!("\"{PROPOSAL_TITLE_2}\""), | 1488 | vec![ |
| 1417 | format!("\"{PROPOSAL_TITLE_1}\""), | 1489 | format!("\"{PROPOSAL_TITLE_3}\""), |
| 1418 | ])?; | 1490 | format!("\"{PROPOSAL_TITLE_2}\""), |
| 1491 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 1492 | ], | ||
| 1493 | )?; | ||
| 1419 | c.succeeds_with(2, true, None)?; | 1494 | c.succeeds_with(2, true, None)?; |
| 1420 | p.expect("updated proposal available (2 ahead 0 behind 'main'). existing version is 2 ahead 1 behind 'main'\r\n")?; | 1495 | p.expect("updated proposal available (2 ahead 0 behind 'main'). existing version is 2 ahead 1 behind 'main'\r\n")?; |
| 1421 | let mut c = p.expect_choice("", vec![ | 1496 | let mut c = p.expect_choice( |
| 1422 | format!("checkout and overwrite existing proposal branch"), | 1497 | "", |
| 1423 | format!("checkout existing outdated proposal branch"), | 1498 | vec![ |
| 1424 | format!("apply to current branch with `git am`"), | 1499 | format!("checkout and overwrite existing proposal branch"), |
| 1425 | format!("download to ./patches"), | 1500 | format!("checkout existing outdated proposal branch"), |
| 1426 | format!("back"), | 1501 | format!("apply to current branch with `git am`"), |
| 1427 | ])?; | 1502 | format!("download to ./patches"), |
| 1503 | format!("back"), | ||
| 1504 | ], | ||
| 1505 | )?; | ||
| 1428 | c.succeeds_with(0, true, Some(0))?; | 1506 | c.succeeds_with(0, true, Some(0))?; |
| 1429 | p.expect("checked out new version of proposal (2 ahead 0 behind 'main'), replacing old version (2 ahead 1 behind 'main')\r\n")?; | 1507 | p.expect("checked out new version of proposal (2 ahead 0 behind 'main'), replacing old version (2 ahead 1 behind 'main')\r\n")?; |
| 1430 | p.expect_end()?; | 1508 | p.expect_end()?; |
diff --git a/tests/ngit_login.rs b/tests/ngit_login.rs index b1e2676..9e708dc 100644 --- a/tests/ngit_login.rs +++ b/tests/ngit_login.rs | |||
| @@ -6,21 +6,27 @@ use test_utils::*; | |||
| 6 | static EXPECTED_NSEC_PROMPT: &str = "nsec"; | 6 | static EXPECTED_NSEC_PROMPT: &str = "nsec"; |
| 7 | 7 | ||
| 8 | fn show_first_time_login_choices(p: &mut CliTester) -> Result<CliTesterChoicePrompt> { | 8 | fn show_first_time_login_choices(p: &mut CliTester) -> Result<CliTesterChoicePrompt> { |
| 9 | p.expect_choice("login to nostr", vec![ | 9 | p.expect_choice( |
| 10 | "secret key (nsec / ncryptsec)".to_string(), | 10 | "login to nostr", |
| 11 | "nostr connect (remote signer)".to_string(), | 11 | vec![ |
| 12 | "create account".to_string(), | 12 | "secret key (nsec / ncryptsec)".to_string(), |
| 13 | "help".to_string(), | 13 | "nostr connect (remote signer)".to_string(), |
| 14 | ]) | 14 | "create account".to_string(), |
| 15 | "help".to_string(), | ||
| 16 | ], | ||
| 17 | ) | ||
| 15 | } | 18 | } |
| 16 | 19 | ||
| 17 | fn first_time_login_choices_succeeds_with_nsec(p: &mut CliTester, nsec: &str) -> Result<()> { | 20 | fn first_time_login_choices_succeeds_with_nsec(p: &mut CliTester, nsec: &str) -> Result<()> { |
| 18 | p.expect_choice("login to nostr", vec![ | 21 | p.expect_choice( |
| 19 | "secret key (nsec / ncryptsec)".to_string(), | 22 | "login to nostr", |
| 20 | "nostr connect (remote signer)".to_string(), | 23 | vec![ |
| 21 | "create account".to_string(), | 24 | "secret key (nsec / ncryptsec)".to_string(), |
| 22 | "help".to_string(), | 25 | "nostr connect (remote signer)".to_string(), |
| 23 | ])? | 26 | "create account".to_string(), |
| 27 | "help".to_string(), | ||
| 28 | ], | ||
| 29 | )? | ||
| 24 | .succeeds_with(0, false, Some(0))?; | 30 | .succeeds_with(0, false, Some(0))?; |
| 25 | 31 | ||
| 26 | p.expect_input(EXPECTED_NSEC_PROMPT)? | 32 | p.expect_input(EXPECTED_NSEC_PROMPT)? |
| @@ -110,9 +116,7 @@ mod with_relays { | |||
| 110 | 116 | ||
| 111 | p.expect("failed to extract account name from account metadata...\r\n")?; | 117 | p.expect("failed to extract account name from account metadata...\r\n")?; |
| 112 | 118 | ||
| 113 | p.expect_end_with( | 119 | p.expect_end_with(format!("logged in as {TEST_KEY_1_NPUB}\r\n").as_str())?; |
| 114 | format!("logged in as {}\r\n", TEST_KEY_1_NPUB).as_str(), | ||
| 115 | )?; | ||
| 116 | for p in [51, 52] { | 120 | for p in [51, 52] { |
| 117 | shutdown_relay(8000 + p)?; | 121 | shutdown_relay(8000 + p)?; |
| 118 | } | 122 | } |
| @@ -131,17 +135,25 @@ mod with_relays { | |||
| 131 | async fn when_latest_metadata_and_relay_list_on_all_relays() -> Result<()> { | 135 | async fn when_latest_metadata_and_relay_list_on_all_relays() -> Result<()> { |
| 132 | run_test_displays_correct_name( | 136 | run_test_displays_correct_name( |
| 133 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 137 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 134 | relay.respond_events(client_id, &subscription_id, &vec![ | 138 | relay.respond_events( |
| 135 | generate_test_key_1_metadata_event("fred"), | 139 | client_id, |
| 136 | generate_test_key_1_relay_list_event_same_as_fallback(), | 140 | &subscription_id, |
| 137 | ])?; | 141 | &vec![ |
| 142 | generate_test_key_1_metadata_event("fred"), | ||
| 143 | generate_test_key_1_relay_list_event_same_as_fallback(), | ||
| 144 | ], | ||
| 145 | )?; | ||
| 138 | Ok(()) | 146 | Ok(()) |
| 139 | }), | 147 | }), |
| 140 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 148 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 141 | relay.respond_events(client_id, &subscription_id, &vec![ | 149 | relay.respond_events( |
| 142 | generate_test_key_1_metadata_event("fred"), | 150 | client_id, |
| 143 | generate_test_key_1_relay_list_event_same_as_fallback(), | 151 | &subscription_id, |
| 144 | ])?; | 152 | &vec![ |
| 153 | generate_test_key_1_metadata_event("fred"), | ||
| 154 | generate_test_key_1_relay_list_event_same_as_fallback(), | ||
| 155 | ], | ||
| 156 | )?; | ||
| 145 | Ok(()) | 157 | Ok(()) |
| 146 | }), | 158 | }), |
| 147 | ) | 159 | ) |
| @@ -156,14 +168,18 @@ mod with_relays { | |||
| 156 | async fn when_metadata_contains_only_display_name() -> Result<()> { | 168 | async fn when_metadata_contains_only_display_name() -> Result<()> { |
| 157 | run_test_displays_correct_name( | 169 | run_test_displays_correct_name( |
| 158 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 170 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 159 | relay.respond_events(client_id, &subscription_id, &vec![ | 171 | relay.respond_events( |
| 160 | nostr::event::EventBuilder::metadata( | 172 | client_id, |
| 161 | &nostr::Metadata::new().display_name("fred"), | 173 | &subscription_id, |
| 162 | ) | 174 | &vec![ |
| 163 | .sign_with_keys(&TEST_KEY_1_KEYS) | 175 | nostr::event::EventBuilder::metadata( |
| 164 | .unwrap(), | 176 | &nostr::Metadata::new().display_name("fred"), |
| 165 | generate_test_key_1_relay_list_event_same_as_fallback(), | 177 | ) |
| 166 | ])?; | 178 | .sign_with_keys(&TEST_KEY_1_KEYS) |
| 179 | .unwrap(), | ||
| 180 | generate_test_key_1_relay_list_event_same_as_fallback(), | ||
| 181 | ], | ||
| 182 | )?; | ||
| 167 | Ok(()) | 183 | Ok(()) |
| 168 | }), | 184 | }), |
| 169 | None, | 185 | None, |
| @@ -189,14 +205,19 @@ mod with_relays { | |||
| 189 | 205 | ||
| 190 | run_test_displays_correct_name( | 206 | run_test_displays_correct_name( |
| 191 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 207 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 192 | relay.respond_events(client_id, &subscription_id, &vec![ | 208 | relay.respond_events( |
| 193 | nostr::event::EventBuilder::metadata( | 209 | client_id, |
| 194 | &nostr::Metadata::new().custom_field("displayName", "fred"), | 210 | &subscription_id, |
| 195 | ) | 211 | &vec![ |
| 196 | .sign_with_keys(&TEST_KEY_1_KEYS) | 212 | nostr::event::EventBuilder::metadata( |
| 197 | .unwrap(), | 213 | &nostr::Metadata::new() |
| 198 | generate_test_key_1_relay_list_event_same_as_fallback(), | 214 | .custom_field("displayName", "fred"), |
| 199 | ])?; | 215 | ) |
| 216 | .sign_with_keys(&TEST_KEY_1_KEYS) | ||
| 217 | .unwrap(), | ||
| 218 | generate_test_key_1_relay_list_event_same_as_fallback(), | ||
| 219 | ], | ||
| 220 | )?; | ||
| 200 | Ok(()) | 221 | Ok(()) |
| 201 | }), | 222 | }), |
| 202 | None, | 223 | None, |
| @@ -210,14 +231,18 @@ mod with_relays { | |||
| 210 | -> Result<()> { | 231 | -> Result<()> { |
| 211 | run_test_displays_fallback_to_npub( | 232 | run_test_displays_fallback_to_npub( |
| 212 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 233 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 213 | relay.respond_events(client_id, &subscription_id, &vec![ | 234 | relay.respond_events( |
| 214 | nostr::event::EventBuilder::metadata( | 235 | client_id, |
| 215 | &nostr::Metadata::new().about("other info in metadata"), | 236 | &subscription_id, |
| 216 | ) | 237 | &vec![ |
| 217 | .sign_with_keys(&TEST_KEY_1_KEYS) | 238 | nostr::event::EventBuilder::metadata( |
| 218 | .unwrap(), | 239 | &nostr::Metadata::new().about("other info in metadata"), |
| 219 | generate_test_key_1_relay_list_event_same_as_fallback(), | 240 | ) |
| 220 | ])?; | 241 | .sign_with_keys(&TEST_KEY_1_KEYS) |
| 242 | .unwrap(), | ||
| 243 | generate_test_key_1_relay_list_event_same_as_fallback(), | ||
| 244 | ], | ||
| 245 | )?; | ||
| 221 | Ok(()) | 246 | Ok(()) |
| 222 | }), | 247 | }), |
| 223 | None, | 248 | None, |
| @@ -232,10 +257,14 @@ mod with_relays { | |||
| 232 | -> Result<()> { | 257 | -> Result<()> { |
| 233 | run_test_displays_correct_name( | 258 | run_test_displays_correct_name( |
| 234 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 259 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 235 | relay.respond_events(client_id, &subscription_id, &vec![ | 260 | relay.respond_events( |
| 236 | generate_test_key_1_metadata_event("fred"), | 261 | client_id, |
| 237 | generate_test_key_1_relay_list_event_same_as_fallback(), | 262 | &subscription_id, |
| 238 | ])?; | 263 | &vec![ |
| 264 | generate_test_key_1_metadata_event("fred"), | ||
| 265 | generate_test_key_1_relay_list_event_same_as_fallback(), | ||
| 266 | ], | ||
| 267 | )?; | ||
| 239 | Ok(()) | 268 | Ok(()) |
| 240 | }), | 269 | }), |
| 241 | None, | 270 | None, |
| @@ -249,15 +278,19 @@ mod with_relays { | |||
| 249 | { | 278 | { |
| 250 | run_test_displays_correct_name( | 279 | run_test_displays_correct_name( |
| 251 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 280 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 252 | relay.respond_events(client_id, &subscription_id, &vec![ | 281 | relay.respond_events( |
| 253 | generate_test_key_1_metadata_event("fred"), | 282 | client_id, |
| 254 | ])?; | 283 | &subscription_id, |
| 284 | &vec![generate_test_key_1_metadata_event("fred")], | ||
| 285 | )?; | ||
| 255 | Ok(()) | 286 | Ok(()) |
| 256 | }), | 287 | }), |
| 257 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 288 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 258 | relay.respond_events(client_id, &subscription_id, &vec![ | 289 | relay.respond_events( |
| 259 | generate_test_key_1_relay_list_event_same_as_fallback(), | 290 | client_id, |
| 260 | ])?; | 291 | &subscription_id, |
| 292 | &vec![generate_test_key_1_relay_list_event_same_as_fallback()], | ||
| 293 | )?; | ||
| 261 | Ok(()) | 294 | Ok(()) |
| 262 | }), | 295 | }), |
| 263 | ) | 296 | ) |
| @@ -269,16 +302,22 @@ mod with_relays { | |||
| 269 | async fn when_some_relays_return_old_metadata_event() -> Result<()> { | 302 | async fn when_some_relays_return_old_metadata_event() -> Result<()> { |
| 270 | run_test_displays_correct_name( | 303 | run_test_displays_correct_name( |
| 271 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 304 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 272 | relay.respond_events(client_id, &subscription_id, &vec![ | 305 | relay.respond_events( |
| 273 | generate_test_key_1_metadata_event("fred"), | 306 | client_id, |
| 274 | generate_test_key_1_relay_list_event_same_as_fallback(), | 307 | &subscription_id, |
| 275 | ])?; | 308 | &vec![ |
| 309 | generate_test_key_1_metadata_event("fred"), | ||
| 310 | generate_test_key_1_relay_list_event_same_as_fallback(), | ||
| 311 | ], | ||
| 312 | )?; | ||
| 276 | Ok(()) | 313 | Ok(()) |
| 277 | }), | 314 | }), |
| 278 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 315 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 279 | relay.respond_events(client_id, &subscription_id, &vec![ | 316 | relay.respond_events( |
| 280 | generate_test_key_1_metadata_event_old("fred old"), | 317 | client_id, |
| 281 | ])?; | 318 | &subscription_id, |
| 319 | &vec![generate_test_key_1_metadata_event_old("fred old")], | ||
| 320 | )?; | ||
| 282 | Ok(()) | 321 | Ok(()) |
| 283 | }), | 322 | }), |
| 284 | ) | 323 | ) |
| @@ -290,16 +329,22 @@ mod with_relays { | |||
| 290 | async fn when_some_relays_return_other_users_metadata() -> Result<()> { | 329 | async fn when_some_relays_return_other_users_metadata() -> Result<()> { |
| 291 | run_test_displays_correct_name( | 330 | run_test_displays_correct_name( |
| 292 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 331 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 293 | relay.respond_events(client_id, &subscription_id, &vec![ | 332 | relay.respond_events( |
| 294 | generate_test_key_2_metadata_event("carole"), | 333 | client_id, |
| 295 | ])?; | 334 | &subscription_id, |
| 335 | &vec![generate_test_key_2_metadata_event("carole")], | ||
| 336 | )?; | ||
| 296 | Ok(()) | 337 | Ok(()) |
| 297 | }), | 338 | }), |
| 298 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 339 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 299 | relay.respond_events(client_id, &subscription_id, &vec![ | 340 | relay.respond_events( |
| 300 | generate_test_key_1_metadata_event_old("fred"), | 341 | client_id, |
| 301 | generate_test_key_1_relay_list_event_same_as_fallback(), | 342 | &subscription_id, |
| 302 | ])?; | 343 | &vec![ |
| 344 | generate_test_key_1_metadata_event_old("fred"), | ||
| 345 | generate_test_key_1_relay_list_event_same_as_fallback(), | ||
| 346 | ], | ||
| 347 | )?; | ||
| 303 | Ok(()) | 348 | Ok(()) |
| 304 | }), | 349 | }), |
| 305 | ) | 350 | ) |
| @@ -312,16 +357,22 @@ mod with_relays { | |||
| 312 | run_test_displays_correct_name( | 357 | run_test_displays_correct_name( |
| 313 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 358 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 314 | let event = generate_test_key_1_kind_event(nostr::Kind::TextNote); | 359 | let event = generate_test_key_1_kind_event(nostr::Kind::TextNote); |
| 315 | relay.respond_events(client_id, &subscription_id, &vec![ | 360 | relay.respond_events( |
| 316 | make_event_old_or_change_user(event, &TEST_KEY_1_KEYS, 0), | 361 | client_id, |
| 317 | ])?; | 362 | &subscription_id, |
| 363 | &vec![make_event_old_or_change_user(event, &TEST_KEY_1_KEYS, 0)], | ||
| 364 | )?; | ||
| 318 | Ok(()) | 365 | Ok(()) |
| 319 | }), | 366 | }), |
| 320 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 367 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 321 | relay.respond_events(client_id, &subscription_id, &vec![ | 368 | relay.respond_events( |
| 322 | generate_test_key_1_metadata_event_old("fred"), | 369 | client_id, |
| 323 | generate_test_key_1_relay_list_event_same_as_fallback(), | 370 | &subscription_id, |
| 324 | ])?; | 371 | &vec![ |
| 372 | generate_test_key_1_metadata_event_old("fred"), | ||
| 373 | generate_test_key_1_relay_list_event_same_as_fallback(), | ||
| 374 | ], | ||
| 375 | )?; | ||
| 325 | Ok(()) | 376 | Ok(()) |
| 326 | }), | 377 | }), |
| 327 | ) | 378 | ) |
| @@ -336,10 +387,14 @@ mod with_relays { | |||
| 336 | async fn displays_correct_name() -> Result<()> { | 387 | async fn displays_correct_name() -> Result<()> { |
| 337 | run_test_when_specifying_command_line_nsec_only_displays_correct_name( | 388 | run_test_when_specifying_command_line_nsec_only_displays_correct_name( |
| 338 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 389 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 339 | relay.respond_events(client_id, &subscription_id, &vec![ | 390 | relay.respond_events( |
| 340 | generate_test_key_1_metadata_event("fred"), | 391 | client_id, |
| 341 | generate_test_key_1_relay_list_event_same_as_fallback(), | 392 | &subscription_id, |
| 342 | ])?; | 393 | &vec![ |
| 394 | generate_test_key_1_metadata_event("fred"), | ||
| 395 | generate_test_key_1_relay_list_event_same_as_fallback(), | ||
| 396 | ], | ||
| 397 | )?; | ||
| 343 | Ok(()) | 398 | Ok(()) |
| 344 | }), | 399 | }), |
| 345 | None, | 400 | None, |
| @@ -357,12 +412,10 @@ mod with_relays { | |||
| 357 | 412 | ||
| 358 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | 413 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { |
| 359 | let test_repo = GitTestRepo::default(); | 414 | let test_repo = GitTestRepo::default(); |
| 360 | let mut p = CliTester::new_from_dir(&test_repo.dir, [ | 415 | let mut p = CliTester::new_from_dir( |
| 361 | "account", | 416 | &test_repo.dir, |
| 362 | "login", | 417 | ["account", "login", "--nsec", TEST_KEY_1_NSEC], |
| 363 | "--nsec", | 418 | ); |
| 364 | TEST_KEY_1_NSEC, | ||
| 365 | ]); | ||
| 366 | 419 | ||
| 367 | p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; | 420 | p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; |
| 368 | 421 | ||
| @@ -434,9 +487,11 @@ mod with_relays { | |||
| 434 | async fn warm_user_and_displays_name() -> Result<()> { | 487 | async fn warm_user_and_displays_name() -> Result<()> { |
| 435 | run_test_when_no_relay_list_found_warns_user_and_uses_npub( | 488 | run_test_when_no_relay_list_found_warns_user_and_uses_npub( |
| 436 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 489 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 437 | relay.respond_events(client_id, &subscription_id, &vec![ | 490 | relay.respond_events( |
| 438 | generate_test_key_1_metadata_event("fred"), | 491 | client_id, |
| 439 | ])?; | 492 | &subscription_id, |
| 493 | &vec![generate_test_key_1_metadata_event("fred")], | ||
| 494 | )?; | ||
| 440 | Ok(()) | 495 | Ok(()) |
| 441 | }), | 496 | }), |
| 442 | None, | 497 | None, |
| @@ -527,17 +582,25 @@ mod with_relays { | |||
| 527 | async fn displays_correct_name() -> Result<()> { | 582 | async fn displays_correct_name() -> Result<()> { |
| 528 | run_test_displays_correct_name( | 583 | run_test_displays_correct_name( |
| 529 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 584 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 530 | relay.respond_events(client_id, &subscription_id, &vec![ | 585 | relay.respond_events( |
| 531 | generate_test_key_1_metadata_event_old("Fred"), | 586 | client_id, |
| 532 | generate_test_key_1_relay_list_event(), | 587 | &subscription_id, |
| 533 | ])?; | 588 | &vec![ |
| 589 | generate_test_key_1_metadata_event_old("Fred"), | ||
| 590 | generate_test_key_1_relay_list_event(), | ||
| 591 | ], | ||
| 592 | )?; | ||
| 534 | Ok(()) | 593 | Ok(()) |
| 535 | }), | 594 | }), |
| 536 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 595 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 537 | relay.respond_events(client_id, &subscription_id, &vec![ | 596 | relay.respond_events( |
| 538 | generate_test_key_1_metadata_event("fred"), | 597 | client_id, |
| 539 | generate_test_key_1_relay_list_event(), | 598 | &subscription_id, |
| 540 | ])?; | 599 | &vec![ |
| 600 | generate_test_key_1_metadata_event("fred"), | ||
| 601 | generate_test_key_1_relay_list_event(), | ||
| 602 | ], | ||
| 603 | )?; | ||
| 541 | Ok(()) | 604 | Ok(()) |
| 542 | }), | 605 | }), |
| 543 | ) | 606 | ) |
| @@ -572,7 +635,7 @@ mod with_offline_flag { | |||
| 572 | 635 | ||
| 573 | p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; | 636 | p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; |
| 574 | 637 | ||
| 575 | p.expect_end_with(format!("logged in as {}\r\n", TEST_KEY_1_NPUB).as_str()) | 638 | p.expect_end_with(format!("logged in as {TEST_KEY_1_NPUB}\r\n").as_str()) |
| 576 | } | 639 | } |
| 577 | 640 | ||
| 578 | #[test] | 641 | #[test] |
| @@ -587,7 +650,7 @@ mod with_offline_flag { | |||
| 587 | 650 | ||
| 588 | p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; | 651 | p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; |
| 589 | 652 | ||
| 590 | p.expect_end_with(format!("logged in as {}\r\n", TEST_KEY_1_NPUB).as_str()) | 653 | p.expect_end_with(format!("logged in as {TEST_KEY_1_NPUB}\r\n").as_str()) |
| 591 | } | 654 | } |
| 592 | 655 | ||
| 593 | mod when_invalid_nsec { | 656 | mod when_invalid_nsec { |
| @@ -609,10 +672,10 @@ mod with_offline_flag { | |||
| 609 | true, | 672 | true, |
| 610 | )?; | 673 | )?; |
| 611 | 674 | ||
| 612 | p.expect_choice("login to nostr", vec![ | 675 | p.expect_choice( |
| 613 | "try again with nsec".to_string(), | 676 | "login to nostr", |
| 614 | "back".to_string(), | 677 | vec!["try again with nsec".to_string(), "back".to_string()], |
| 615 | ])? | 678 | )? |
| 616 | .succeeds_with(0, false, Some(0))?; | 679 | .succeeds_with(0, false, Some(0))?; |
| 617 | } | 680 | } |
| 618 | 681 | ||
| @@ -621,7 +684,7 @@ mod with_offline_flag { | |||
| 621 | 684 | ||
| 622 | p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; | 685 | p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; |
| 623 | 686 | ||
| 624 | p.expect_end_with(format!("logged in as {}\r\n", TEST_KEY_1_NPUB).as_str()) | 687 | p.expect_end_with(format!("logged in as {TEST_KEY_1_NPUB}\r\n").as_str()) |
| 625 | } | 688 | } |
| 626 | } | 689 | } |
| 627 | } | 690 | } |
| @@ -632,31 +695,25 @@ mod with_offline_flag { | |||
| 632 | #[test] | 695 | #[test] |
| 633 | fn valid_nsec_param_succeeds_without_prompts() -> Result<()> { | 696 | fn valid_nsec_param_succeeds_without_prompts() -> Result<()> { |
| 634 | let test_repo = GitTestRepo::default(); | 697 | let test_repo = GitTestRepo::default(); |
| 635 | let mut p = CliTester::new_from_dir(&test_repo.dir, [ | 698 | let mut p = CliTester::new_from_dir( |
| 636 | "account", | 699 | &test_repo.dir, |
| 637 | "login", | 700 | ["account", "login", "--offline", "--nsec", TEST_KEY_1_NSEC], |
| 638 | "--offline", | 701 | ); |
| 639 | "--nsec", | ||
| 640 | TEST_KEY_1_NSEC, | ||
| 641 | ]); | ||
| 642 | 702 | ||
| 643 | p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; | 703 | p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; |
| 644 | 704 | ||
| 645 | p.expect_end_with( | 705 | p.expect_end_with( |
| 646 | format!("logged in as {} via cli arguments\r\n", TEST_KEY_1_NPUB).as_str(), | 706 | format!("logged in as {TEST_KEY_1_NPUB} via cli arguments\r\n").as_str(), |
| 647 | ) | 707 | ) |
| 648 | } | 708 | } |
| 649 | 709 | ||
| 650 | #[test] | 710 | #[test] |
| 651 | fn invalid_nsec_param_fails_without_prompts() -> Result<()> { | 711 | fn invalid_nsec_param_fails_without_prompts() -> Result<()> { |
| 652 | let test_repo = GitTestRepo::default(); | 712 | let test_repo = GitTestRepo::default(); |
| 653 | let mut p = CliTester::new_from_dir(&test_repo.dir, [ | 713 | let mut p = CliTester::new_from_dir( |
| 654 | "account", | 714 | &test_repo.dir, |
| 655 | "login", | 715 | ["account", "login", "--offline", "--nsec", TEST_INVALID_NSEC], |
| 656 | "--offline", | 716 | ); |
| 657 | "--nsec", | ||
| 658 | TEST_INVALID_NSEC, | ||
| 659 | ]); | ||
| 660 | 717 | ||
| 661 | p.expect_end_with( | 718 | p.expect_end_with( |
| 662 | "Error: invalid nsec parameter\r\n\r\nCaused by:\r\n Invalid secret key\r\n", | 719 | "Error: invalid nsec parameter\r\n\r\nCaused by:\r\n Invalid secret key\r\n", |
| @@ -670,38 +727,44 @@ mod with_offline_flag { | |||
| 670 | #[test] | 727 | #[test] |
| 671 | fn valid_nsec_param_succeeds_without_prompts() -> Result<()> { | 728 | fn valid_nsec_param_succeeds_without_prompts() -> Result<()> { |
| 672 | let test_repo = GitTestRepo::default(); | 729 | let test_repo = GitTestRepo::default(); |
| 673 | let mut p = CliTester::new_from_dir(&test_repo.dir, [ | 730 | let mut p = CliTester::new_from_dir( |
| 674 | "account", | 731 | &test_repo.dir, |
| 675 | "login", | 732 | [ |
| 676 | "--offline", | 733 | "account", |
| 677 | "--nsec", | 734 | "login", |
| 678 | TEST_KEY_1_NSEC, | 735 | "--offline", |
| 679 | "--password", | 736 | "--nsec", |
| 680 | TEST_PASSWORD, | 737 | TEST_KEY_1_NSEC, |
| 681 | ]); | 738 | "--password", |
| 739 | TEST_PASSWORD, | ||
| 740 | ], | ||
| 741 | ); | ||
| 682 | p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; | 742 | p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; |
| 683 | 743 | ||
| 684 | p.expect_end_with( | 744 | p.expect_end_with( |
| 685 | format!("logged in as {} via cli arguments\r\n", TEST_KEY_1_NPUB).as_str(), | 745 | format!("logged in as {TEST_KEY_1_NPUB} via cli arguments\r\n").as_str(), |
| 686 | ) | 746 | ) |
| 687 | } | 747 | } |
| 688 | 748 | ||
| 689 | #[test] | 749 | #[test] |
| 690 | fn parameters_can_be_called_globally() -> Result<()> { | 750 | fn parameters_can_be_called_globally() -> Result<()> { |
| 691 | let test_repo = GitTestRepo::default(); | 751 | let test_repo = GitTestRepo::default(); |
| 692 | let mut p = CliTester::new_from_dir(&test_repo.dir, [ | 752 | let mut p = CliTester::new_from_dir( |
| 693 | "--nsec", | 753 | &test_repo.dir, |
| 694 | TEST_KEY_1_NSEC, | 754 | [ |
| 695 | "--password", | 755 | "--nsec", |
| 696 | TEST_PASSWORD, | 756 | TEST_KEY_1_NSEC, |
| 697 | "account", | 757 | "--password", |
| 698 | "login", | 758 | TEST_PASSWORD, |
| 699 | "--offline", | 759 | "account", |
| 700 | ]); | 760 | "login", |
| 761 | "--offline", | ||
| 762 | ], | ||
| 763 | ); | ||
| 701 | p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; | 764 | p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; |
| 702 | 765 | ||
| 703 | p.expect_end_with( | 766 | p.expect_end_with( |
| 704 | format!("logged in as {} via cli arguments\r\n", TEST_KEY_1_NPUB).as_str(), | 767 | format!("logged in as {TEST_KEY_1_NPUB} via cli arguments\r\n").as_str(), |
| 705 | ) | 768 | ) |
| 706 | } | 769 | } |
| 707 | 770 | ||
| @@ -712,19 +775,22 @@ mod with_offline_flag { | |||
| 712 | fn valid_nsec_param_succeeds_without_prompts_and_logs_in() -> Result<()> { | 775 | fn valid_nsec_param_succeeds_without_prompts_and_logs_in() -> Result<()> { |
| 713 | standard_first_time_login_with_nsec()?.exit()?; | 776 | standard_first_time_login_with_nsec()?.exit()?; |
| 714 | let test_repo = GitTestRepo::default(); | 777 | let test_repo = GitTestRepo::default(); |
| 715 | let mut p = CliTester::new_from_dir(&test_repo.dir, [ | 778 | let mut p = CliTester::new_from_dir( |
| 716 | "account", | 779 | &test_repo.dir, |
| 717 | "login", | 780 | [ |
| 718 | "--offline", | 781 | "account", |
| 719 | "--nsec", | 782 | "login", |
| 720 | TEST_KEY_2_NSEC, | 783 | "--offline", |
| 721 | "--password", | 784 | "--nsec", |
| 722 | TEST_PASSWORD, | 785 | TEST_KEY_2_NSEC, |
| 723 | ]); | 786 | "--password", |
| 787 | TEST_PASSWORD, | ||
| 788 | ], | ||
| 789 | ); | ||
| 724 | p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; | 790 | p.expect("saved login details to local git config. you are only logged in to this local repository.\r\n")?; |
| 725 | 791 | ||
| 726 | p.expect_end_with( | 792 | p.expect_end_with( |
| 727 | format!("logged in as {} via cli arguments\r\n", TEST_KEY_2_NPUB).as_str(), | 793 | format!("logged in as {TEST_KEY_2_NPUB} via cli arguments\r\n").as_str(), |
| 728 | ) | 794 | ) |
| 729 | } | 795 | } |
| 730 | } | 796 | } |
diff --git a/tests/ngit_send.rs b/tests/ngit_send.rs index 629454b..2cd5956 100644 --- a/tests/ngit_send.rs +++ b/tests/ngit_send.rs | |||
| @@ -181,10 +181,14 @@ async fn prep_run_create_proposal( | |||
| 181 | 8051, | 181 | 8051, |
| 182 | None, | 182 | None, |
| 183 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 183 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 184 | relay.respond_events(client_id, &subscription_id, &vec![ | 184 | relay.respond_events( |
| 185 | generate_test_key_1_metadata_event("fred"), | 185 | client_id, |
| 186 | generate_test_key_1_relay_list_event(), | 186 | &subscription_id, |
| 187 | ])?; | 187 | &vec![ |
| 188 | generate_test_key_1_metadata_event("fred"), | ||
| 189 | generate_test_key_1_relay_list_event(), | ||
| 190 | ], | ||
| 191 | )?; | ||
| 188 | Ok(()) | 192 | Ok(()) |
| 189 | }), | 193 | }), |
| 190 | ), | 194 | ), |
| @@ -194,9 +198,11 @@ async fn prep_run_create_proposal( | |||
| 194 | 8055, | 198 | 8055, |
| 195 | None, | 199 | None, |
| 196 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 200 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 197 | relay.respond_events(client_id, &subscription_id, &vec![ | 201 | relay.respond_events( |
| 198 | generate_repo_ref_event(), | 202 | client_id, |
| 199 | ])?; | 203 | &subscription_id, |
| 204 | &vec![generate_repo_ref_event()], | ||
| 205 | )?; | ||
| 200 | Ok(()) | 206 | Ok(()) |
| 201 | }), | 207 | }), |
| 202 | ), | 208 | ), |
| @@ -321,7 +327,7 @@ mod when_cover_letter_details_specified_with_range_of_head_2_sends_cover_letter_ | |||
| 321 | +some content\n\\ \ | 327 | +some content\n\\ \ |
| 322 | No newline at end of file\n\ | 328 | No newline at end of file\n\ |
| 323 | --\n\ | 329 | --\n\ |
| 324 | libgit2 1.9.0\n\ | 330 | libgit2 1.9.1\n\ |
| 325 | \n\ | 331 | \n\ |
| 326 | ", | 332 | ", |
| 327 | ); | 333 | ); |
| @@ -347,7 +353,7 @@ mod when_cover_letter_details_specified_with_range_of_head_2_sends_cover_letter_ | |||
| 347 | +some content\n\\ \ | 353 | +some content\n\\ \ |
| 348 | No newline at end of file\n\ | 354 | No newline at end of file\n\ |
| 349 | --\n\ | 355 | --\n\ |
| 350 | libgit2 1.9.0\n\ | 356 | libgit2 1.9.1\n\ |
| 351 | \n\ | 357 | \n\ |
| 352 | ", | 358 | ", |
| 353 | ); | 359 | ); |
| @@ -762,10 +768,14 @@ mod when_cover_letter_details_specified_with_range_of_head_2_sends_cover_letter_ | |||
| 762 | 8051, | 768 | 8051, |
| 763 | None, | 769 | None, |
| 764 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 770 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 765 | relay.respond_events(client_id, &subscription_id, &vec![ | 771 | relay.respond_events( |
| 766 | generate_test_key_1_metadata_event("fred"), | 772 | client_id, |
| 767 | generate_test_key_1_relay_list_event(), | 773 | &subscription_id, |
| 768 | ])?; | 774 | &vec![ |
| 775 | generate_test_key_1_metadata_event("fred"), | ||
| 776 | generate_test_key_1_relay_list_event(), | ||
| 777 | ], | ||
| 778 | )?; | ||
| 769 | Ok(()) | 779 | Ok(()) |
| 770 | }), | 780 | }), |
| 771 | ), | 781 | ), |
| @@ -775,9 +785,11 @@ mod when_cover_letter_details_specified_with_range_of_head_2_sends_cover_letter_ | |||
| 775 | 8055, | 785 | 8055, |
| 776 | None, | 786 | None, |
| 777 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 787 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 778 | relay.respond_events(client_id, &subscription_id, &vec![ | 788 | relay.respond_events( |
| 779 | generate_repo_ref_event(), | 789 | client_id, |
| 780 | ])?; | 790 | &subscription_id, |
| 791 | &vec![generate_repo_ref_event()], | ||
| 792 | )?; | ||
| 781 | Ok(()) | 793 | Ok(()) |
| 782 | }), | 794 | }), |
| 783 | ), | 795 | ), |
| @@ -836,10 +848,14 @@ mod when_cover_letter_details_specified_with_range_of_head_2_sends_cover_letter_ | |||
| 836 | 8051, | 848 | 8051, |
| 837 | None, | 849 | None, |
| 838 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 850 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 839 | relay.respond_events(client_id, &subscription_id, &vec![ | 851 | relay.respond_events( |
| 840 | generate_test_key_1_metadata_event("fred"), | 852 | client_id, |
| 841 | generate_test_key_1_relay_list_event(), | 853 | &subscription_id, |
| 842 | ])?; | 854 | &vec![ |
| 855 | generate_test_key_1_metadata_event("fred"), | ||
| 856 | generate_test_key_1_relay_list_event(), | ||
| 857 | ], | ||
| 858 | )?; | ||
| 843 | Ok(()) | 859 | Ok(()) |
| 844 | }), | 860 | }), |
| 845 | ), | 861 | ), |
| @@ -849,9 +865,11 @@ mod when_cover_letter_details_specified_with_range_of_head_2_sends_cover_letter_ | |||
| 849 | 8055, | 865 | 8055, |
| 850 | None, | 866 | None, |
| 851 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 867 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 852 | relay.respond_events(client_id, &subscription_id, &vec![ | 868 | relay.respond_events( |
| 853 | generate_repo_ref_event(), | 869 | client_id, |
| 854 | ])?; | 870 | &subscription_id, |
| 871 | &vec![generate_repo_ref_event()], | ||
| 872 | )?; | ||
| 855 | Ok(()) | 873 | Ok(()) |
| 856 | }), | 874 | }), |
| 857 | ), | 875 | ), |
| @@ -904,10 +922,14 @@ mod when_cover_letter_details_specified_with_range_of_head_2_sends_cover_letter_ | |||
| 904 | 8051, | 922 | 8051, |
| 905 | None, | 923 | None, |
| 906 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 924 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 907 | relay.respond_events(client_id, &subscription_id, &vec![ | 925 | relay.respond_events( |
| 908 | generate_test_key_1_metadata_event("fred"), | 926 | client_id, |
| 909 | generate_test_key_1_relay_list_event(), | 927 | &subscription_id, |
| 910 | ])?; | 928 | &vec![ |
| 929 | generate_test_key_1_metadata_event("fred"), | ||
| 930 | generate_test_key_1_relay_list_event(), | ||
| 931 | ], | ||
| 932 | )?; | ||
| 911 | Ok(()) | 933 | Ok(()) |
| 912 | }), | 934 | }), |
| 913 | ), | 935 | ), |
| @@ -917,9 +939,11 @@ mod when_cover_letter_details_specified_with_range_of_head_2_sends_cover_letter_ | |||
| 917 | 8055, | 939 | 8055, |
| 918 | None, | 940 | None, |
| 919 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 941 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 920 | relay.respond_events(client_id, &subscription_id, &vec![ | 942 | relay.respond_events( |
| 921 | generate_repo_ref_event(), | 943 | client_id, |
| 922 | ])?; | 944 | &subscription_id, |
| 945 | &vec![generate_repo_ref_event()], | ||
| 946 | )?; | ||
| 923 | Ok(()) | 947 | Ok(()) |
| 924 | }), | 948 | }), |
| 925 | ), | 949 | ), |
| @@ -992,10 +1016,14 @@ mod when_no_cover_letter_flag_set_with_range_of_head_2_sends_2_patches_without_c | |||
| 992 | 8051, | 1016 | 8051, |
| 993 | None, | 1017 | None, |
| 994 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 1018 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 995 | relay.respond_events(client_id, &subscription_id, &vec![ | 1019 | relay.respond_events( |
| 996 | generate_test_key_1_metadata_event("fred"), | 1020 | client_id, |
| 997 | generate_test_key_1_relay_list_event(), | 1021 | &subscription_id, |
| 998 | ])?; | 1022 | &vec![ |
| 1023 | generate_test_key_1_metadata_event("fred"), | ||
| 1024 | generate_test_key_1_relay_list_event(), | ||
| 1025 | ], | ||
| 1026 | )?; | ||
| 999 | Ok(()) | 1027 | Ok(()) |
| 1000 | }), | 1028 | }), |
| 1001 | ), | 1029 | ), |
| @@ -1005,9 +1033,11 @@ mod when_no_cover_letter_flag_set_with_range_of_head_2_sends_2_patches_without_c | |||
| 1005 | 8055, | 1033 | 8055, |
| 1006 | None, | 1034 | None, |
| 1007 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 1035 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 1008 | relay.respond_events(client_id, &subscription_id, &vec![ | 1036 | relay.respond_events( |
| 1009 | generate_repo_ref_event(), | 1037 | client_id, |
| 1010 | ])?; | 1038 | &subscription_id, |
| 1039 | &vec![generate_repo_ref_event()], | ||
| 1040 | )?; | ||
| 1011 | Ok(()) | 1041 | Ok(()) |
| 1012 | }), | 1042 | }), |
| 1013 | ), | 1043 | ), |
| @@ -1174,13 +1204,16 @@ mod when_range_ommited_prompts_for_selection_defaulting_ahead_of_main { | |||
| 1174 | fn expect_msgs_first(p: &mut CliTester) -> Result<()> { | 1204 | fn expect_msgs_first(p: &mut CliTester) -> Result<()> { |
| 1175 | p.expect("fetching updates...\r\n")?; | 1205 | p.expect("fetching updates...\r\n")?; |
| 1176 | p.expect_eventually("\r\n")?; // may be 'no updates' or some updates | 1206 | p.expect_eventually("\r\n")?; // may be 'no updates' or some updates |
| 1177 | let mut selector = p.expect_multi_select("select commits for proposal", vec![ | 1207 | let mut selector = p.expect_multi_select( |
| 1178 | "(Joe Bloggs) add t4.md [feature] fe973a8".to_string(), | 1208 | "select commits for proposal", |
| 1179 | "(Joe Bloggs) add t3.md 232efb3".to_string(), | 1209 | vec![ |
| 1180 | "(Joe Bloggs) add t2.md [main] 431b84e".to_string(), | 1210 | "(Joe Bloggs) add t4.md [feature] fe973a8".to_string(), |
| 1181 | "(Joe Bloggs) add t1.md af474d8".to_string(), | 1211 | "(Joe Bloggs) add t3.md 232efb3".to_string(), |
| 1182 | "(Joe Bloggs) Initial commit 9ee507f".to_string(), | 1212 | "(Joe Bloggs) add t2.md [main] 431b84e".to_string(), |
| 1183 | ])?; | 1213 | "(Joe Bloggs) add t1.md af474d8".to_string(), |
| 1214 | "(Joe Bloggs) Initial commit 9ee507f".to_string(), | ||
| 1215 | ], | ||
| 1216 | )?; | ||
| 1184 | selector.succeeds_with(vec![0, 1], false, vec![0, 1])?; | 1217 | selector.succeeds_with(vec![0, 1], false, vec![0, 1])?; |
| 1185 | p.expect("creating proposal from 2 commits:\r\n")?; | 1218 | p.expect("creating proposal from 2 commits:\r\n")?; |
| 1186 | p.expect("fe973a8 add t4.md\r\n")?; | 1219 | p.expect("fe973a8 add t4.md\r\n")?; |
| @@ -1205,10 +1238,14 @@ mod when_range_ommited_prompts_for_selection_defaulting_ahead_of_main { | |||
| 1205 | 8051, | 1238 | 8051, |
| 1206 | None, | 1239 | None, |
| 1207 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 1240 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 1208 | relay.respond_events(client_id, &subscription_id, &vec![ | 1241 | relay.respond_events( |
| 1209 | generate_test_key_1_metadata_event("fred"), | 1242 | client_id, |
| 1210 | generate_test_key_1_relay_list_event(), | 1243 | &subscription_id, |
| 1211 | ])?; | 1244 | &vec![ |
| 1245 | generate_test_key_1_metadata_event("fred"), | ||
| 1246 | generate_test_key_1_relay_list_event(), | ||
| 1247 | ], | ||
| 1248 | )?; | ||
| 1212 | Ok(()) | 1249 | Ok(()) |
| 1213 | }), | 1250 | }), |
| 1214 | ), | 1251 | ), |
| @@ -1218,9 +1255,11 @@ mod when_range_ommited_prompts_for_selection_defaulting_ahead_of_main { | |||
| 1218 | 8055, | 1255 | 8055, |
| 1219 | None, | 1256 | None, |
| 1220 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 1257 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 1221 | relay.respond_events(client_id, &subscription_id, &vec![ | 1258 | relay.respond_events( |
| 1222 | generate_repo_ref_event(), | 1259 | client_id, |
| 1223 | ])?; | 1260 | &subscription_id, |
| 1261 | &vec![generate_repo_ref_event()], | ||
| 1262 | )?; | ||
| 1224 | Ok(()) | 1263 | Ok(()) |
| 1225 | }), | 1264 | }), |
| 1226 | ), | 1265 | ), |
| @@ -1262,10 +1301,14 @@ mod when_range_ommited_prompts_for_selection_defaulting_ahead_of_main { | |||
| 1262 | 8051, | 1301 | 8051, |
| 1263 | None, | 1302 | None, |
| 1264 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 1303 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 1265 | relay.respond_events(client_id, &subscription_id, &vec![ | 1304 | relay.respond_events( |
| 1266 | generate_test_key_1_metadata_event("fred"), | 1305 | client_id, |
| 1267 | generate_test_key_1_relay_list_event(), | 1306 | &subscription_id, |
| 1268 | ])?; | 1307 | &vec![ |
| 1308 | generate_test_key_1_metadata_event("fred"), | ||
| 1309 | generate_test_key_1_relay_list_event(), | ||
| 1310 | ], | ||
| 1311 | )?; | ||
| 1269 | Ok(()) | 1312 | Ok(()) |
| 1270 | }), | 1313 | }), |
| 1271 | ), | 1314 | ), |
| @@ -1275,9 +1318,11 @@ mod when_range_ommited_prompts_for_selection_defaulting_ahead_of_main { | |||
| 1275 | 8055, | 1318 | 8055, |
| 1276 | None, | 1319 | None, |
| 1277 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 1320 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 1278 | relay.respond_events(client_id, &subscription_id, &vec![ | 1321 | relay.respond_events( |
| 1279 | generate_repo_ref_event(), | 1322 | client_id, |
| 1280 | ])?; | 1323 | &subscription_id, |
| 1324 | &vec![generate_repo_ref_event()], | ||
| 1325 | )?; | ||
| 1281 | Ok(()) | 1326 | Ok(()) |
| 1282 | }), | 1327 | }), |
| 1283 | ), | 1328 | ), |
| @@ -1361,8 +1406,7 @@ mod root_proposal_specified_using_in_reply_to_with_range_of_head_2_and_cover_let | |||
| 1361 | p.expect("updates: 1 new maintainer, 1 announcement update, 1 proposal\r\n")?; | 1406 | p.expect("updates: 1 new maintainer, 1 announcement update, 1 proposal\r\n")?; |
| 1362 | let proposal_root_bech32 = get_pretend_proposal_root_event().id.to_bech32().unwrap(); | 1407 | let proposal_root_bech32 = get_pretend_proposal_root_event().id.to_bech32().unwrap(); |
| 1363 | p.expect(format!( | 1408 | p.expect(format!( |
| 1364 | "creating proposal revision for: {}\r\n", | 1409 | "creating proposal revision for: {proposal_root_bech32}\r\n", |
| 1365 | proposal_root_bech32, | ||
| 1366 | ))?; | 1410 | ))?; |
| 1367 | p.expect("creating proposal from 2 commits:\r\n")?; | 1411 | p.expect("creating proposal from 2 commits:\r\n")?; |
| 1368 | p.expect("fe973a8 add t4.md\r\n")?; | 1412 | p.expect("fe973a8 add t4.md\r\n")?; |
| @@ -1394,11 +1438,15 @@ mod root_proposal_specified_using_in_reply_to_with_range_of_head_2_and_cover_let | |||
| 1394 | 8051, | 1438 | 8051, |
| 1395 | None, | 1439 | None, |
| 1396 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 1440 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 1397 | relay.respond_events(client_id, &subscription_id, &vec![ | 1441 | relay.respond_events( |
| 1398 | generate_test_key_1_metadata_event("fred"), | 1442 | client_id, |
| 1399 | generate_test_key_1_relay_list_event(), | 1443 | &subscription_id, |
| 1400 | get_pretend_proposal_root_event(), | 1444 | &vec![ |
| 1401 | ])?; | 1445 | generate_test_key_1_metadata_event("fred"), |
| 1446 | generate_test_key_1_relay_list_event(), | ||
| 1447 | get_pretend_proposal_root_event(), | ||
| 1448 | ], | ||
| 1449 | )?; | ||
| 1402 | Ok(()) | 1450 | Ok(()) |
| 1403 | }), | 1451 | }), |
| 1404 | ), | 1452 | ), |
| @@ -1408,10 +1456,11 @@ mod root_proposal_specified_using_in_reply_to_with_range_of_head_2_and_cover_let | |||
| 1408 | 8055, | 1456 | 8055, |
| 1409 | None, | 1457 | None, |
| 1410 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 1458 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 1411 | relay.respond_events(client_id, &subscription_id, &vec![ | 1459 | relay.respond_events( |
| 1412 | generate_repo_ref_event(), | 1460 | client_id, |
| 1413 | get_pretend_proposal_root_event(), | 1461 | &subscription_id, |
| 1414 | ])?; | 1462 | &vec![generate_repo_ref_event(), get_pretend_proposal_root_event()], |
| 1463 | )?; | ||
| 1415 | Ok(()) | 1464 | Ok(()) |
| 1416 | }), | 1465 | }), |
| 1417 | ), | 1466 | ), |
| @@ -1452,11 +1501,15 @@ mod root_proposal_specified_using_in_reply_to_with_range_of_head_2_and_cover_let | |||
| 1452 | 8051, | 1501 | 8051, |
| 1453 | None, | 1502 | None, |
| 1454 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 1503 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 1455 | relay.respond_events(client_id, &subscription_id, &vec![ | 1504 | relay.respond_events( |
| 1456 | generate_test_key_1_metadata_event("fred"), | 1505 | client_id, |
| 1457 | generate_test_key_1_relay_list_event(), | 1506 | &subscription_id, |
| 1458 | get_pretend_proposal_root_event(), | 1507 | &vec![ |
| 1459 | ])?; | 1508 | generate_test_key_1_metadata_event("fred"), |
| 1509 | generate_test_key_1_relay_list_event(), | ||
| 1510 | get_pretend_proposal_root_event(), | ||
| 1511 | ], | ||
| 1512 | )?; | ||
| 1460 | Ok(()) | 1513 | Ok(()) |
| 1461 | }), | 1514 | }), |
| 1462 | ), | 1515 | ), |
| @@ -1466,10 +1519,11 @@ mod root_proposal_specified_using_in_reply_to_with_range_of_head_2_and_cover_let | |||
| 1466 | 8055, | 1519 | 8055, |
| 1467 | None, | 1520 | None, |
| 1468 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 1521 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 1469 | relay.respond_events(client_id, &subscription_id, &vec![ | 1522 | relay.respond_events( |
| 1470 | generate_repo_ref_event(), | 1523 | client_id, |
| 1471 | get_pretend_proposal_root_event(), | 1524 | &subscription_id, |
| 1472 | ])?; | 1525 | &vec![generate_repo_ref_event(), get_pretend_proposal_root_event()], |
| 1526 | )?; | ||
| 1473 | Ok(()) | 1527 | Ok(()) |
| 1474 | }), | 1528 | }), |
| 1475 | ), | 1529 | ), |
| @@ -1646,11 +1700,15 @@ mod in_reply_to_mentions_issue { | |||
| 1646 | 8051, | 1700 | 8051, |
| 1647 | None, | 1701 | None, |
| 1648 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 1702 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 1649 | relay.respond_events(client_id, &subscription_id, &vec![ | 1703 | relay.respond_events( |
| 1650 | generate_test_key_1_metadata_event("fred"), | 1704 | client_id, |
| 1651 | generate_test_key_1_relay_list_event(), | 1705 | &subscription_id, |
| 1652 | get_pretend_issue_event(), | 1706 | &vec![ |
| 1653 | ])?; | 1707 | generate_test_key_1_metadata_event("fred"), |
| 1708 | generate_test_key_1_relay_list_event(), | ||
| 1709 | get_pretend_issue_event(), | ||
| 1710 | ], | ||
| 1711 | )?; | ||
| 1654 | Ok(()) | 1712 | Ok(()) |
| 1655 | }), | 1713 | }), |
| 1656 | ), | 1714 | ), |
| @@ -1660,10 +1718,11 @@ mod in_reply_to_mentions_issue { | |||
| 1660 | 8055, | 1718 | 8055, |
| 1661 | None, | 1719 | None, |
| 1662 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 1720 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 1663 | relay.respond_events(client_id, &subscription_id, &vec![ | 1721 | relay.respond_events( |
| 1664 | generate_repo_ref_event(), | 1722 | client_id, |
| 1665 | get_pretend_issue_event(), | 1723 | &subscription_id, |
| 1666 | ])?; | 1724 | &vec![generate_repo_ref_event(), get_pretend_issue_event()], |
| 1725 | )?; | ||
| 1667 | Ok(()) | 1726 | Ok(()) |
| 1668 | }), | 1727 | }), |
| 1669 | ), | 1728 | ), |
| @@ -1765,10 +1824,14 @@ mod in_reply_to_mentions_npub_and_nprofile_which_get_mentioned_in_proposal_root | |||
| 1765 | 8051, | 1824 | 8051, |
| 1766 | None, | 1825 | None, |
| 1767 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 1826 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 1768 | relay.respond_events(client_id, &subscription_id, &vec![ | 1827 | relay.respond_events( |
| 1769 | generate_test_key_1_metadata_event("fred"), | 1828 | client_id, |
| 1770 | generate_test_key_1_relay_list_event(), | 1829 | &subscription_id, |
| 1771 | ])?; | 1830 | &vec![ |
| 1831 | generate_test_key_1_metadata_event("fred"), | ||
| 1832 | generate_test_key_1_relay_list_event(), | ||
| 1833 | ], | ||
| 1834 | )?; | ||
| 1772 | Ok(()) | 1835 | Ok(()) |
| 1773 | }), | 1836 | }), |
| 1774 | ), | 1837 | ), |
| @@ -1778,9 +1841,11 @@ mod in_reply_to_mentions_npub_and_nprofile_which_get_mentioned_in_proposal_root | |||
| 1778 | 8055, | 1841 | 8055, |
| 1779 | None, | 1842 | None, |
| 1780 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { | 1843 | Some(&|relay, client_id, subscription_id, _| -> Result<()> { |
| 1781 | relay.respond_events(client_id, &subscription_id, &vec![ | 1844 | relay.respond_events( |
| 1782 | generate_repo_ref_event(), | 1845 | client_id, |
| 1783 | ])?; | 1846 | &subscription_id, |
| 1847 | &vec![generate_repo_ref_event()], | ||
| 1848 | )?; | ||
| 1784 | Ok(()) | 1849 | Ok(()) |
| 1785 | }), | 1850 | }), |
| 1786 | ), | 1851 | ), |