diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-07-24 10:58:07 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-07-24 10:58:07 +0100 |
| commit | 6d086a6608652193898ec548382e780733ea2f5a (patch) | |
| tree | 29515ad88e09ae82eb3239927d241da2111efad1 /tests/pull.rs | |
| parent | b67376ff54abeab31422921ba5f4883d5d3dccdb (diff) | |
test: refactor `pull` and `push` to abstract code
into lib which makes reading and maintaining tests easier
Diffstat (limited to 'tests/pull.rs')
| -rw-r--r-- | tests/pull.rs | 446 |
1 files changed, 19 insertions, 427 deletions
diff --git a/tests/pull.rs b/tests/pull.rs index 0febd5c..70319bd 100644 --- a/tests/pull.rs +++ b/tests/pull.rs | |||
| @@ -3,128 +3,6 @@ use futures::join; | |||
| 3 | use serial_test::serial; | 3 | use serial_test::serial; |
| 4 | use test_utils::{git::GitTestRepo, relay::Relay, *}; | 4 | use test_utils::{git::GitTestRepo, relay::Relay, *}; |
| 5 | 5 | ||
| 6 | static FEATURE_BRANCH_NAME_1: &str = "feature-example-t"; | ||
| 7 | static FEATURE_BRANCH_NAME_2: &str = "feature-example-f"; | ||
| 8 | static FEATURE_BRANCH_NAME_3: &str = "feature-example-c"; | ||
| 9 | |||
| 10 | static PROPOSAL_TITLE_1: &str = "proposal a"; | ||
| 11 | static PROPOSAL_TITLE_2: &str = "proposal b"; | ||
| 12 | static PROPOSAL_TITLE_3: &str = "proposal c"; | ||
| 13 | |||
| 14 | fn cli_tester_create_proposals() -> Result<GitTestRepo> { | ||
| 15 | let git_repo = GitTestRepo::default(); | ||
| 16 | git_repo.populate()?; | ||
| 17 | cli_tester_create_proposal( | ||
| 18 | &git_repo, | ||
| 19 | FEATURE_BRANCH_NAME_1, | ||
| 20 | "a", | ||
| 21 | Some((PROPOSAL_TITLE_1, "proposal a description")), | ||
| 22 | None, | ||
| 23 | )?; | ||
| 24 | cli_tester_create_proposal( | ||
| 25 | &git_repo, | ||
| 26 | FEATURE_BRANCH_NAME_2, | ||
| 27 | "b", | ||
| 28 | Some((PROPOSAL_TITLE_2, "proposal b description")), | ||
| 29 | None, | ||
| 30 | )?; | ||
| 31 | cli_tester_create_proposal( | ||
| 32 | &git_repo, | ||
| 33 | FEATURE_BRANCH_NAME_3, | ||
| 34 | "c", | ||
| 35 | Some((PROPOSAL_TITLE_3, "proposal c description")), | ||
| 36 | None, | ||
| 37 | )?; | ||
| 38 | Ok(git_repo) | ||
| 39 | } | ||
| 40 | |||
| 41 | fn create_and_populate_branch( | ||
| 42 | test_repo: &GitTestRepo, | ||
| 43 | branch_name: &str, | ||
| 44 | prefix: &str, | ||
| 45 | only_one_commit: bool, | ||
| 46 | ) -> Result<()> { | ||
| 47 | test_repo.checkout("main")?; | ||
| 48 | test_repo.create_branch(branch_name)?; | ||
| 49 | test_repo.checkout(branch_name)?; | ||
| 50 | std::fs::write( | ||
| 51 | test_repo.dir.join(format!("{}3.md", prefix)), | ||
| 52 | "some content", | ||
| 53 | )?; | ||
| 54 | test_repo.stage_and_commit(format!("add {}3.md", prefix).as_str())?; | ||
| 55 | if !only_one_commit { | ||
| 56 | std::fs::write( | ||
| 57 | test_repo.dir.join(format!("{}4.md", prefix)), | ||
| 58 | "some content", | ||
| 59 | )?; | ||
| 60 | test_repo.stage_and_commit(format!("add {}4.md", prefix).as_str())?; | ||
| 61 | } | ||
| 62 | Ok(()) | ||
| 63 | } | ||
| 64 | |||
| 65 | fn cli_tester_create_proposal( | ||
| 66 | test_repo: &GitTestRepo, | ||
| 67 | branch_name: &str, | ||
| 68 | prefix: &str, | ||
| 69 | cover_letter_title_and_description: Option<(&str, &str)>, | ||
| 70 | in_reply_to: Option<String>, | ||
| 71 | ) -> Result<()> { | ||
| 72 | create_and_populate_branch(test_repo, branch_name, prefix, false)?; | ||
| 73 | |||
| 74 | if let Some(in_reply_to) = in_reply_to { | ||
| 75 | let mut p = CliTester::new_from_dir( | ||
| 76 | &test_repo.dir, | ||
| 77 | [ | ||
| 78 | "--nsec", | ||
| 79 | TEST_KEY_1_NSEC, | ||
| 80 | "--password", | ||
| 81 | TEST_PASSWORD, | ||
| 82 | "--disable-cli-spinners", | ||
| 83 | "send", | ||
| 84 | "HEAD~2", | ||
| 85 | "--no-cover-letter", | ||
| 86 | "--in-reply-to", | ||
| 87 | in_reply_to.as_str(), | ||
| 88 | ], | ||
| 89 | ); | ||
| 90 | p.expect_end_eventually()?; | ||
| 91 | } else if let Some((title, description)) = cover_letter_title_and_description { | ||
| 92 | let mut p = CliTester::new_from_dir( | ||
| 93 | &test_repo.dir, | ||
| 94 | [ | ||
| 95 | "--nsec", | ||
| 96 | TEST_KEY_1_NSEC, | ||
| 97 | "--password", | ||
| 98 | TEST_PASSWORD, | ||
| 99 | "--disable-cli-spinners", | ||
| 100 | "send", | ||
| 101 | "HEAD~2", | ||
| 102 | "--title", | ||
| 103 | format!("\"{title}\"").as_str(), | ||
| 104 | "--description", | ||
| 105 | format!("\"{description}\"").as_str(), | ||
| 106 | ], | ||
| 107 | ); | ||
| 108 | p.expect_end_eventually()?; | ||
| 109 | } else { | ||
| 110 | let mut p = CliTester::new_from_dir( | ||
| 111 | &test_repo.dir, | ||
| 112 | [ | ||
| 113 | "--nsec", | ||
| 114 | TEST_KEY_1_NSEC, | ||
| 115 | "--password", | ||
| 116 | TEST_PASSWORD, | ||
| 117 | "--disable-cli-spinners", | ||
| 118 | "send", | ||
| 119 | "HEAD~2", | ||
| 120 | "--no-cover-letter", | ||
| 121 | ], | ||
| 122 | ); | ||
| 123 | p.expect_end_eventually()?; | ||
| 124 | } | ||
| 125 | Ok(()) | ||
| 126 | } | ||
| 127 | |||
| 128 | mod when_main_is_checked_out { | 6 | mod when_main_is_checked_out { |
| 129 | use super::*; | 7 | use super::*; |
| 130 | 8 | ||
| @@ -153,33 +31,8 @@ mod when_main_is_checked_out { | |||
| 153 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | 31 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { |
| 154 | cli_tester_create_proposals()?; | 32 | cli_tester_create_proposals()?; |
| 155 | 33 | ||
| 156 | let test_repo = GitTestRepo::default(); | 34 | let test_repo = create_repo_with_first_proposal_branch_pulled_and_checkedout()?; |
| 157 | test_repo.populate()?; | ||
| 158 | 35 | ||
| 159 | // create proposal branch | ||
| 160 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | ||
| 161 | p.expect("fetching updates...\r\n")?; | ||
| 162 | p.expect_eventually("\r\n")?; // some updates listed here | ||
| 163 | let mut c = p.expect_choice( | ||
| 164 | "all proposals", | ||
| 165 | vec![ | ||
| 166 | format!("\"{PROPOSAL_TITLE_3}\""), | ||
| 167 | format!("\"{PROPOSAL_TITLE_2}\""), | ||
| 168 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 169 | ], | ||
| 170 | )?; | ||
| 171 | c.succeeds_with(2, true, None)?; | ||
| 172 | let mut c = p.expect_choice( | ||
| 173 | "", | ||
| 174 | vec![ | ||
| 175 | format!("create and checkout proposal branch (2 ahead 0 behind 'main')"), | ||
| 176 | format!("apply to current branch with `git am`"), | ||
| 177 | format!("download to ./patches"), | ||
| 178 | format!("back"), | ||
| 179 | ], | ||
| 180 | )?; | ||
| 181 | c.succeeds_with(0, false, Some(0))?; | ||
| 182 | p.expect_end_eventually()?; | ||
| 183 | test_repo.checkout("main")?; | 36 | test_repo.checkout("main")?; |
| 184 | 37 | ||
| 185 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); | 38 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); |
| @@ -295,37 +148,8 @@ mod when_branch_is_checked_out { | |||
| 295 | r55.events.push(generate_test_key_1_relay_list_event()); | 148 | r55.events.push(generate_test_key_1_relay_list_event()); |
| 296 | 149 | ||
| 297 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | 150 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { |
| 298 | cli_tester_create_proposals()?; | 151 | let (_, test_repo) = |
| 299 | 152 | create_proposals_and_repo_with_first_proposal_pulled_and_checkedout()?; | |
| 300 | let test_repo = GitTestRepo::default(); | ||
| 301 | test_repo.populate()?; | ||
| 302 | |||
| 303 | // create proposal branch | ||
| 304 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | ||
| 305 | p.expect("fetching updates...\r\n")?; | ||
| 306 | p.expect_eventually("\r\n")?; // some updates listed here | ||
| 307 | let mut c = p.expect_choice( | ||
| 308 | "all proposals", | ||
| 309 | vec![ | ||
| 310 | format!("\"{PROPOSAL_TITLE_3}\""), | ||
| 311 | format!("\"{PROPOSAL_TITLE_2}\""), | ||
| 312 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 313 | ], | ||
| 314 | )?; | ||
| 315 | c.succeeds_with(2, true, None)?; | ||
| 316 | let mut c = p.expect_choice( | ||
| 317 | "", | ||
| 318 | vec![ | ||
| 319 | format!( | ||
| 320 | "create and checkout proposal branch (2 ahead 0 behind 'main')" | ||
| 321 | ), | ||
| 322 | format!("apply to current branch with `git am`"), | ||
| 323 | format!("download to ./patches"), | ||
| 324 | format!("back"), | ||
| 325 | ], | ||
| 326 | )?; | ||
| 327 | c.succeeds_with(0, false, Some(0))?; | ||
| 328 | p.expect_end_eventually()?; | ||
| 329 | 153 | ||
| 330 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); | 154 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); |
| 331 | p.expect("fetching updates...\r\n")?; | 155 | p.expect("fetching updates...\r\n")?; |
| @@ -376,37 +200,8 @@ mod when_branch_is_checked_out { | |||
| 376 | 200 | ||
| 377 | let cli_tester_handle = | 201 | let cli_tester_handle = |
| 378 | std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { | 202 | std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { |
| 379 | let originating_repo = cli_tester_create_proposals()?; | 203 | let (originating_repo, test_repo) = |
| 380 | 204 | create_proposals_and_repo_with_first_proposal_pulled_and_checkedout()?; | |
| 381 | let test_repo = GitTestRepo::default(); | ||
| 382 | test_repo.populate()?; | ||
| 383 | |||
| 384 | // create proposal branch | ||
| 385 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | ||
| 386 | p.expect("fetching updates...\r\n")?; | ||
| 387 | p.expect_eventually("\r\n")?; // some updates listed here | ||
| 388 | let mut c = p.expect_choice( | ||
| 389 | "all proposals", | ||
| 390 | vec![ | ||
| 391 | format!("\"{PROPOSAL_TITLE_3}\""), | ||
| 392 | format!("\"{PROPOSAL_TITLE_2}\""), | ||
| 393 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 394 | ], | ||
| 395 | )?; | ||
| 396 | c.succeeds_with(2, true, None)?; | ||
| 397 | let mut c = p.expect_choice( | ||
| 398 | "", | ||
| 399 | vec![ | ||
| 400 | format!( | ||
| 401 | "create and checkout proposal branch (2 ahead 0 behind 'main')" | ||
| 402 | ), | ||
| 403 | format!("apply to current branch with `git am`"), | ||
| 404 | format!("download to ./patches"), | ||
| 405 | format!("back"), | ||
| 406 | ], | ||
| 407 | )?; | ||
| 408 | c.succeeds_with(0, false, Some(0))?; | ||
| 409 | p.expect_end_eventually()?; | ||
| 410 | 205 | ||
| 411 | // remove latest commit so it is behind | 206 | // remove latest commit so it is behind |
| 412 | let branch_name = test_repo.get_checked_out_branch_name()?; | 207 | let branch_name = test_repo.get_checked_out_branch_name()?; |
| @@ -467,37 +262,8 @@ mod when_branch_is_checked_out { | |||
| 467 | 262 | ||
| 468 | let cli_tester_handle = | 263 | let cli_tester_handle = |
| 469 | std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { | 264 | std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { |
| 470 | let originating_repo = cli_tester_create_proposals()?; | 265 | let (originating_repo, test_repo) = |
| 471 | 266 | create_proposals_and_repo_with_first_proposal_pulled_and_checkedout()?; | |
| 472 | let test_repo = GitTestRepo::default(); | ||
| 473 | test_repo.populate()?; | ||
| 474 | |||
| 475 | // create proposal branch | ||
| 476 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | ||
| 477 | p.expect("fetching updates...\r\n")?; | ||
| 478 | p.expect_eventually("\r\n")?; // some updates listed here | ||
| 479 | let mut c = p.expect_choice( | ||
| 480 | "all proposals", | ||
| 481 | vec![ | ||
| 482 | format!("\"{PROPOSAL_TITLE_3}\""), | ||
| 483 | format!("\"{PROPOSAL_TITLE_2}\""), | ||
| 484 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 485 | ], | ||
| 486 | )?; | ||
| 487 | c.succeeds_with(2, true, None)?; | ||
| 488 | let mut c = p.expect_choice( | ||
| 489 | "", | ||
| 490 | vec![ | ||
| 491 | format!( | ||
| 492 | "create and checkout proposal branch (2 ahead 0 behind 'main')" | ||
| 493 | ), | ||
| 494 | format!("apply to current branch with `git am`"), | ||
| 495 | format!("download to ./patches"), | ||
| 496 | format!("back"), | ||
| 497 | ], | ||
| 498 | )?; | ||
| 499 | c.succeeds_with(0, false, Some(0))?; | ||
| 500 | p.expect_end_eventually()?; | ||
| 501 | 267 | ||
| 502 | // remove latest commit so it is behind | 268 | // remove latest commit so it is behind |
| 503 | let branch_name = test_repo.get_checked_out_branch_name()?; | 269 | let branch_name = test_repo.get_checked_out_branch_name()?; |
| @@ -577,37 +343,8 @@ mod when_branch_is_checked_out { | |||
| 577 | r55.events.push(generate_test_key_1_relay_list_event()); | 343 | r55.events.push(generate_test_key_1_relay_list_event()); |
| 578 | 344 | ||
| 579 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | 345 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { |
| 580 | let originating_repo = cli_tester_create_proposals()?; | 346 | let (originating_repo, test_repo) = |
| 581 | 347 | create_proposals_and_repo_with_first_proposal_pulled_and_checkedout()?; | |
| 582 | let test_repo = GitTestRepo::default(); | ||
| 583 | test_repo.populate()?; | ||
| 584 | |||
| 585 | // create proposal branch | ||
| 586 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | ||
| 587 | p.expect("fetching updates...\r\n")?; | ||
| 588 | p.expect_eventually("\r\n")?; // some updates listed here | ||
| 589 | let mut c = p.expect_choice( | ||
| 590 | "all proposals", | ||
| 591 | vec![ | ||
| 592 | format!("\"{PROPOSAL_TITLE_3}\""), | ||
| 593 | format!("\"{PROPOSAL_TITLE_2}\""), | ||
| 594 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 595 | ], | ||
| 596 | )?; | ||
| 597 | c.succeeds_with(2, true, None)?; | ||
| 598 | let mut c = p.expect_choice( | ||
| 599 | "", | ||
| 600 | vec![ | ||
| 601 | format!( | ||
| 602 | "create and checkout proposal branch (2 ahead 0 behind 'main')" | ||
| 603 | ), | ||
| 604 | format!("apply to current branch with `git am`"), | ||
| 605 | format!("download to ./patches"), | ||
| 606 | format!("back"), | ||
| 607 | ], | ||
| 608 | )?; | ||
| 609 | c.succeeds_with(0, false, Some(0))?; | ||
| 610 | p.expect_end_eventually()?; | ||
| 611 | 348 | ||
| 612 | // remove latest commit so it is behind | 349 | // remove latest commit so it is behind |
| 613 | let branch_name = test_repo.get_checked_out_branch_name()?; | 350 | let branch_name = test_repo.get_checked_out_branch_name()?; |
| @@ -705,37 +442,8 @@ mod when_branch_is_checked_out { | |||
| 705 | r55.events.push(generate_test_key_1_relay_list_event()); | 442 | r55.events.push(generate_test_key_1_relay_list_event()); |
| 706 | 443 | ||
| 707 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | 444 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { |
| 708 | cli_tester_create_proposals()?; | 445 | let (_, test_repo) = |
| 709 | 446 | create_proposals_and_repo_with_first_proposal_pulled_and_checkedout()?; | |
| 710 | let test_repo = GitTestRepo::default(); | ||
| 711 | test_repo.populate()?; | ||
| 712 | |||
| 713 | // create proposal branch | ||
| 714 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | ||
| 715 | p.expect("fetching updates...\r\n")?; | ||
| 716 | p.expect_eventually("\r\n")?; // some updates listed here | ||
| 717 | let mut c = p.expect_choice( | ||
| 718 | "all proposals", | ||
| 719 | vec![ | ||
| 720 | format!("\"{PROPOSAL_TITLE_3}\""), | ||
| 721 | format!("\"{PROPOSAL_TITLE_2}\""), | ||
| 722 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 723 | ], | ||
| 724 | )?; | ||
| 725 | c.succeeds_with(2, true, None)?; | ||
| 726 | let mut c = p.expect_choice( | ||
| 727 | "", | ||
| 728 | vec![ | ||
| 729 | format!( | ||
| 730 | "create and checkout proposal branch (2 ahead 0 behind 'main')" | ||
| 731 | ), | ||
| 732 | format!("apply to current branch with `git am`"), | ||
| 733 | format!("download to ./patches"), | ||
| 734 | format!("back"), | ||
| 735 | ], | ||
| 736 | )?; | ||
| 737 | c.succeeds_with(0, false, Some(0))?; | ||
| 738 | p.expect_end_eventually()?; | ||
| 739 | 447 | ||
| 740 | // remove latest commit so it is behind | 448 | // remove latest commit so it is behind |
| 741 | let branch_name = test_repo.get_checked_out_branch_name()?; | 449 | let branch_name = test_repo.get_checked_out_branch_name()?; |
| @@ -811,37 +519,8 @@ mod when_branch_is_checked_out { | |||
| 811 | 519 | ||
| 812 | let cli_tester_handle = std::thread::spawn( | 520 | let cli_tester_handle = std::thread::spawn( |
| 813 | move || -> Result<(GitTestRepo, GitTestRepo)> { | 521 | move || -> Result<(GitTestRepo, GitTestRepo)> { |
| 814 | let originating_repo = cli_tester_create_proposals()?; | 522 | let (originating_repo, test_repo) = |
| 815 | 523 | create_proposals_and_repo_with_first_proposal_pulled_and_checkedout()?; | |
| 816 | let test_repo = GitTestRepo::default(); | ||
| 817 | test_repo.populate()?; | ||
| 818 | |||
| 819 | // create proposal branch | ||
| 820 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | ||
| 821 | p.expect("fetching updates...\r\n")?; | ||
| 822 | p.expect_eventually("\r\n")?; // some updates listed here | ||
| 823 | let mut c = p.expect_choice( | ||
| 824 | "all proposals", | ||
| 825 | vec![ | ||
| 826 | format!("\"{PROPOSAL_TITLE_3}\""), | ||
| 827 | format!("\"{PROPOSAL_TITLE_2}\""), | ||
| 828 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 829 | ], | ||
| 830 | )?; | ||
| 831 | c.succeeds_with(2, true, None)?; | ||
| 832 | let mut c = p.expect_choice( | ||
| 833 | "", | ||
| 834 | vec![ | ||
| 835 | format!( | ||
| 836 | "create and checkout proposal branch (2 ahead 0 behind 'main')" | ||
| 837 | ), | ||
| 838 | format!("apply to current branch with `git am`"), | ||
| 839 | format!("download to ./patches"), | ||
| 840 | format!("back"), | ||
| 841 | ], | ||
| 842 | )?; | ||
| 843 | c.succeeds_with(0, false, Some(0))?; | ||
| 844 | p.expect_end_eventually()?; | ||
| 845 | 524 | ||
| 846 | // add another commit (so we have a local branch 1 ahead) | 525 | // add another commit (so we have a local branch 1 ahead) |
| 847 | std::fs::write(test_repo.dir.join("ammended-commit.md"), "some content")?; | 526 | std::fs::write(test_repo.dir.join("ammended-commit.md"), "some content")?; |
| @@ -898,37 +577,8 @@ mod when_branch_is_checked_out { | |||
| 898 | r55.events.push(generate_test_key_1_relay_list_event()); | 577 | r55.events.push(generate_test_key_1_relay_list_event()); |
| 899 | 578 | ||
| 900 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | 579 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { |
| 901 | cli_tester_create_proposals()?; | 580 | let (_, test_repo) = |
| 902 | 581 | create_proposals_and_repo_with_first_proposal_pulled_and_checkedout()?; | |
| 903 | let test_repo = GitTestRepo::default(); | ||
| 904 | test_repo.populate()?; | ||
| 905 | |||
| 906 | // create proposal branch | ||
| 907 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | ||
| 908 | p.expect("fetching updates...\r\n")?; | ||
| 909 | p.expect_eventually("\r\n")?; // some updates listed here | ||
| 910 | let mut c = p.expect_choice( | ||
| 911 | "all proposals", | ||
| 912 | vec![ | ||
| 913 | format!("\"{PROPOSAL_TITLE_3}\""), | ||
| 914 | format!("\"{PROPOSAL_TITLE_2}\""), | ||
| 915 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 916 | ], | ||
| 917 | )?; | ||
| 918 | c.succeeds_with(2, true, None)?; | ||
| 919 | let mut c = p.expect_choice( | ||
| 920 | "", | ||
| 921 | vec![ | ||
| 922 | format!( | ||
| 923 | "create and checkout proposal branch (2 ahead 0 behind 'main')" | ||
| 924 | ), | ||
| 925 | format!("apply to current branch with `git am`"), | ||
| 926 | format!("download to ./patches"), | ||
| 927 | format!("back"), | ||
| 928 | ], | ||
| 929 | )?; | ||
| 930 | c.succeeds_with(0, false, Some(0))?; | ||
| 931 | p.expect_end_eventually()?; | ||
| 932 | 582 | ||
| 933 | // add another commit (so we have a local branch 1 ahead) | 583 | // add another commit (so we have a local branch 1 ahead) |
| 934 | std::fs::write(test_repo.dir.join("ammended-commit.md"), "some content")?; | 584 | std::fs::write(test_repo.dir.join("ammended-commit.md"), "some content")?; |
| @@ -1004,37 +654,8 @@ mod when_branch_is_checked_out { | |||
| 1004 | 654 | ||
| 1005 | let cli_tester_handle: JoinHandle<Result<(GitTestRepo, GitTestRepo)>> = | 655 | let cli_tester_handle: JoinHandle<Result<(GitTestRepo, GitTestRepo)>> = |
| 1006 | tokio::task::spawn_blocking(move || { | 656 | tokio::task::spawn_blocking(move || { |
| 1007 | // create 3 proposals | 657 | let (_, test_repo) = |
| 1008 | let _ = cli_tester_create_proposals()?; | 658 | create_proposals_and_repo_with_first_proposal_pulled_and_checkedout()?; |
| 1009 | // download the origianl version of the first proposal | ||
| 1010 | let test_repo = GitTestRepo::default(); | ||
| 1011 | test_repo.populate()?; | ||
| 1012 | |||
| 1013 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | ||
| 1014 | p.expect("fetching updates...\r\n")?; | ||
| 1015 | p.expect_eventually("\r\n")?; // some updates listed here | ||
| 1016 | let mut c = p.expect_choice( | ||
| 1017 | "all proposals", | ||
| 1018 | vec![ | ||
| 1019 | format!("\"{PROPOSAL_TITLE_3}\""), | ||
| 1020 | format!("\"{PROPOSAL_TITLE_2}\""), | ||
| 1021 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 1022 | ], | ||
| 1023 | )?; | ||
| 1024 | c.succeeds_with(2, true, None)?; | ||
| 1025 | let mut c = p.expect_choice( | ||
| 1026 | "", | ||
| 1027 | vec![ | ||
| 1028 | format!( | ||
| 1029 | "create and checkout proposal branch (2 ahead 0 behind 'main')" | ||
| 1030 | ), | ||
| 1031 | format!("apply to current branch with `git am`"), | ||
| 1032 | format!("download to ./patches"), | ||
| 1033 | format!("back"), | ||
| 1034 | ], | ||
| 1035 | )?; | ||
| 1036 | c.succeeds_with(0, false, Some(0))?; | ||
| 1037 | p.expect_end_eventually()?; | ||
| 1038 | 659 | ||
| 1039 | // get proposal id of first | 660 | // get proposal id of first |
| 1040 | let client = Client::default(); | 661 | let client = Client::default(); |
| @@ -1131,37 +752,8 @@ mod when_branch_is_checked_out { | |||
| 1131 | 752 | ||
| 1132 | let cli_tester_handle: JoinHandle<Result<()>> = tokio::task::spawn_blocking( | 753 | let cli_tester_handle: JoinHandle<Result<()>> = tokio::task::spawn_blocking( |
| 1133 | move || { | 754 | move || { |
| 1134 | // create 3 proposals | 755 | let (_, test_repo) = |
| 1135 | let _ = cli_tester_create_proposals()?; | 756 | create_proposals_and_repo_with_first_proposal_pulled_and_checkedout()?; |
| 1136 | // download the origianl version of the first proposal | ||
| 1137 | let test_repo = GitTestRepo::default(); | ||
| 1138 | test_repo.populate()?; | ||
| 1139 | |||
| 1140 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); | ||
| 1141 | p.expect("fetching updates...\r\n")?; | ||
| 1142 | p.expect_eventually("\r\n")?; // some updates listed here | ||
| 1143 | let mut c = p.expect_choice( | ||
| 1144 | "all proposals", | ||
| 1145 | vec![ | ||
| 1146 | format!("\"{PROPOSAL_TITLE_3}\""), | ||
| 1147 | format!("\"{PROPOSAL_TITLE_2}\""), | ||
| 1148 | format!("\"{PROPOSAL_TITLE_1}\""), | ||
| 1149 | ], | ||
| 1150 | )?; | ||
| 1151 | c.succeeds_with(2, true, None)?; | ||
| 1152 | let mut c = p.expect_choice( | ||
| 1153 | "", | ||
| 1154 | vec![ | ||
| 1155 | format!( | ||
| 1156 | "create and checkout proposal branch (2 ahead 0 behind 'main')" | ||
| 1157 | ), | ||
| 1158 | format!("apply to current branch with `git am`"), | ||
| 1159 | format!("download to ./patches"), | ||
| 1160 | format!("back"), | ||
| 1161 | ], | ||
| 1162 | )?; | ||
| 1163 | c.succeeds_with(0, false, Some(0))?; | ||
| 1164 | p.expect_end_eventually()?; | ||
| 1165 | 757 | ||
| 1166 | // get proposal id of first | 758 | // get proposal id of first |
| 1167 | let client = Client::default(); | 759 | let client = Client::default(); |