diff options
Diffstat (limited to 'tests/pull.rs')
| -rw-r--r-- | tests/pull.rs | 406 |
1 files changed, 365 insertions, 41 deletions
diff --git a/tests/pull.rs b/tests/pull.rs index ecd64ff..0febd5c 100644 --- a/tests/pull.rs +++ b/tests/pull.rs | |||
| @@ -156,7 +156,30 @@ mod when_main_is_checked_out { | |||
| 156 | let test_repo = GitTestRepo::default(); | 156 | let test_repo = GitTestRepo::default(); |
| 157 | test_repo.populate()?; | 157 | test_repo.populate()?; |
| 158 | 158 | ||
| 159 | create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?; | 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()?; | ||
| 160 | test_repo.checkout("main")?; | 183 | test_repo.checkout("main")?; |
| 161 | 184 | ||
| 162 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); | 185 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); |
| @@ -277,7 +300,32 @@ mod when_branch_is_checked_out { | |||
| 277 | let test_repo = GitTestRepo::default(); | 300 | let test_repo = GitTestRepo::default(); |
| 278 | test_repo.populate()?; | 301 | test_repo.populate()?; |
| 279 | 302 | ||
| 280 | create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?; | 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()?; | ||
| 281 | 329 | ||
| 282 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); | 330 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); |
| 283 | p.expect("fetching updates...\r\n")?; | 331 | p.expect("fetching updates...\r\n")?; |
| @@ -333,7 +381,44 @@ mod when_branch_is_checked_out { | |||
| 333 | let test_repo = GitTestRepo::default(); | 381 | let test_repo = GitTestRepo::default(); |
| 334 | test_repo.populate()?; | 382 | test_repo.populate()?; |
| 335 | 383 | ||
| 336 | create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", true)?; | 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 | |||
| 411 | // remove latest commit so it is behind | ||
| 412 | let branch_name = test_repo.get_checked_out_branch_name()?; | ||
| 413 | test_repo.checkout("main")?; | ||
| 414 | test_repo.git_repo.branch( | ||
| 415 | &branch_name, | ||
| 416 | &test_repo | ||
| 417 | .git_repo | ||
| 418 | .find_commit(test_repo.get_tip_of_local_branch(&branch_name)?)? | ||
| 419 | .parent(0)?, | ||
| 420 | true, | ||
| 421 | )?; | ||
| 337 | 422 | ||
| 338 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); | 423 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); |
| 339 | p.expect_end_eventually()?; | 424 | p.expect_end_eventually()?; |
| @@ -387,13 +472,49 @@ mod when_branch_is_checked_out { | |||
| 387 | let test_repo = GitTestRepo::default(); | 472 | let test_repo = GitTestRepo::default(); |
| 388 | test_repo.populate()?; | 473 | test_repo.populate()?; |
| 389 | 474 | ||
| 390 | create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", true)?; | 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 | |||
| 502 | // remove latest commit so it is behind | ||
| 503 | let branch_name = test_repo.get_checked_out_branch_name()?; | ||
| 504 | test_repo.checkout("main")?; | ||
| 505 | test_repo.git_repo.branch( | ||
| 506 | &branch_name, | ||
| 507 | &test_repo | ||
| 508 | .git_repo | ||
| 509 | .find_commit(test_repo.get_tip_of_local_branch(&branch_name)?)? | ||
| 510 | .parent(0)?, | ||
| 511 | true, | ||
| 512 | )?; | ||
| 391 | 513 | ||
| 392 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); | 514 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); |
| 393 | p.expect("fetching updates...\r\n")?; | 515 | p.expect("fetching updates...\r\n")?; |
| 394 | p.expect_eventually("\r\n")?; // some updates listed here | 516 | p.expect_eventually("\r\n")?; // some updates listed here |
| 395 | p.expect("applied 1 new commits\r\n")?; | 517 | p.expect_end_with("applied 1 new commits\r\n")?; |
| 396 | p.expect_end()?; | ||
| 397 | 518 | ||
| 398 | for p in [51, 52, 53, 55, 56] { | 519 | for p in [51, 52, 53, 55, 56] { |
| 399 | relay::shutdown_relay(8000 + p)?; | 520 | relay::shutdown_relay(8000 + p)?; |
| @@ -421,7 +542,10 @@ mod when_branch_is_checked_out { | |||
| 421 | let (originating_repo, test_repo) = prep_and_run().await?; | 542 | let (originating_repo, test_repo) = prep_and_run().await?; |
| 422 | assert_eq!( | 543 | assert_eq!( |
| 423 | originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, | 544 | originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, |
| 424 | test_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, | 545 | test_repo.get_tip_of_local_branch(&get_proposal_branch_name( |
| 546 | &test_repo, | ||
| 547 | FEATURE_BRANCH_NAME_1 | ||
| 548 | )?)?, | ||
| 425 | ); | 549 | ); |
| 426 | Ok(()) | 550 | Ok(()) |
| 427 | } | 551 | } |
| @@ -453,20 +577,72 @@ mod when_branch_is_checked_out { | |||
| 453 | r55.events.push(generate_test_key_1_relay_list_event()); | 577 | r55.events.push(generate_test_key_1_relay_list_event()); |
| 454 | 578 | ||
| 455 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | 579 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { |
| 456 | cli_tester_create_proposals()?; | 580 | let originating_repo = cli_tester_create_proposals()?; |
| 457 | 581 | ||
| 458 | let test_repo = GitTestRepo::default(); | 582 | let test_repo = GitTestRepo::default(); |
| 459 | test_repo.populate()?; | 583 | test_repo.populate()?; |
| 460 | 584 | ||
| 461 | // simulating amending an older version of the proposal commits on the current | 585 | // create proposal branch |
| 462 | // branch | 586 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 463 | create_and_populate_branch( | 587 | p.expect("fetching updates...\r\n")?; |
| 464 | &test_repo, | 588 | p.expect_eventually("\r\n")?; // some updates listed here |
| 465 | FEATURE_BRANCH_NAME_1, | 589 | let mut c = p.expect_choice( |
| 466 | "a-changed", | 590 | "all proposals", |
| 467 | false, | 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 | ], | ||
| 468 | )?; | 608 | )?; |
| 609 | c.succeeds_with(0, false, Some(0))?; | ||
| 610 | p.expect_end_eventually()?; | ||
| 611 | |||
| 612 | // remove latest commit so it is behind | ||
| 613 | let branch_name = test_repo.get_checked_out_branch_name()?; | ||
| 614 | test_repo.checkout("main")?; | ||
| 615 | test_repo.git_repo.branch( | ||
| 616 | &branch_name, | ||
| 617 | &test_repo | ||
| 618 | .git_repo | ||
| 619 | .find_commit(test_repo.get_tip_of_local_branch(&branch_name)?)? | ||
| 620 | .parent(0)?, | ||
| 621 | true, | ||
| 622 | )?; | ||
| 623 | // add another commit (so we have an ammened local branch) | ||
| 624 | test_repo.checkout(&branch_name)?; | ||
| 625 | std::fs::write(test_repo.dir.join("ammended-commit.md"), "some content")?; | ||
| 626 | test_repo.stage_and_commit("add ammended-commit.md")?; | ||
| 627 | test_repo.checkout("main")?; | ||
| 469 | 628 | ||
| 629 | // create and send a revision from another repository | ||
| 630 | originating_repo.checkout("main")?; | ||
| 631 | test_repo.git_repo.branch( | ||
| 632 | &branch_name, | ||
| 633 | &test_repo | ||
| 634 | .git_repo | ||
| 635 | .find_commit(test_repo.get_tip_of_local_branch(&branch_name)?)? | ||
| 636 | .parent(0)?, | ||
| 637 | true, | ||
| 638 | )?; | ||
| 639 | originating_repo.checkout(&branch_name)?; | ||
| 640 | test_repo.checkout(&branch_name)?; | ||
| 641 | std::fs::write(test_repo.dir.join("ammended-commit.md"), "some content")?; | ||
| 642 | test_repo.stage_and_commit("add ammended-commit.md")?; | ||
| 643 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["push", "--force"]); | ||
| 644 | p.expect_end_eventually()?; | ||
| 645 | // test when branch is ammended an older version of the proposal | ||
| 470 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); | 646 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); |
| 471 | p.expect("fetching updates...\r\n")?; | 647 | p.expect("fetching updates...\r\n")?; |
| 472 | p.expect_eventually("\r\n")?; // some updates listed here | 648 | p.expect_eventually("\r\n")?; // some updates listed here |
| @@ -534,17 +710,51 @@ mod when_branch_is_checked_out { | |||
| 534 | let test_repo = GitTestRepo::default(); | 710 | let test_repo = GitTestRepo::default(); |
| 535 | test_repo.populate()?; | 711 | test_repo.populate()?; |
| 536 | 712 | ||
| 537 | // simulating checking out the proposal (the commits_ids will match) | 713 | // create proposal branch |
| 538 | create_and_populate_branch(&test_repo, "different-branch-name", "a", false)?; | 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 | |||
| 740 | // remove latest commit so it is behind | ||
| 741 | let branch_name = test_repo.get_checked_out_branch_name()?; | ||
| 539 | test_repo.checkout("main")?; | 742 | test_repo.checkout("main")?; |
| 540 | // simulating amending the proposal | 743 | test_repo.git_repo.branch( |
| 541 | create_and_populate_branch( | 744 | &branch_name, |
| 542 | &test_repo, | 745 | &test_repo |
| 543 | FEATURE_BRANCH_NAME_1, | 746 | .git_repo |
| 544 | "a-changed", | 747 | .find_commit(test_repo.get_tip_of_local_branch(&branch_name)?)? |
| 545 | false, | 748 | .parent(0)?, |
| 749 | true, | ||
| 546 | )?; | 750 | )?; |
| 751 | // add another commit (so we have an ammened local branch) | ||
| 752 | test_repo.checkout(&branch_name)?; | ||
| 753 | std::fs::write(test_repo.dir.join("ammended-commit.md"), "some content")?; | ||
| 754 | test_repo.stage_and_commit("add ammended-commit.md")?; | ||
| 755 | test_repo.checkout("main")?; | ||
| 547 | 756 | ||
| 757 | // run test | ||
| 548 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); | 758 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); |
| 549 | p.expect("fetching updates...\r\n")?; | 759 | p.expect("fetching updates...\r\n")?; |
| 550 | p.expect_eventually("\r\n")?; // some updates listed here | 760 | p.expect_eventually("\r\n")?; // some updates listed here |
| @@ -606,11 +816,39 @@ mod when_branch_is_checked_out { | |||
| 606 | let test_repo = GitTestRepo::default(); | 816 | let test_repo = GitTestRepo::default(); |
| 607 | test_repo.populate()?; | 817 | test_repo.populate()?; |
| 608 | 818 | ||
| 609 | create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?; | 819 | // create proposal branch |
| 610 | // add appended commit to local branch | 820 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 611 | std::fs::write(test_repo.dir.join("appended.md"), "some content")?; | 821 | p.expect("fetching updates...\r\n")?; |
| 612 | test_repo.stage_and_commit("appended commit")?; | 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()?; | ||
| 613 | 845 | ||
| 846 | // add another commit (so we have a local branch 1 ahead) | ||
| 847 | std::fs::write(test_repo.dir.join("ammended-commit.md"), "some content")?; | ||
| 848 | test_repo.stage_and_commit("add ammended-commit.md")?; | ||
| 849 | test_repo.checkout("main")?; | ||
| 850 | |||
| 851 | // run test | ||
| 614 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); | 852 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); |
| 615 | p.expect("fetching updates...\r\n")?; | 853 | p.expect("fetching updates...\r\n")?; |
| 616 | p.expect_eventually("\r\n")?; // some updates listed here | 854 | p.expect_eventually("\r\n")?; // some updates listed here |
| @@ -665,11 +903,39 @@ mod when_branch_is_checked_out { | |||
| 665 | let test_repo = GitTestRepo::default(); | 903 | let test_repo = GitTestRepo::default(); |
| 666 | test_repo.populate()?; | 904 | test_repo.populate()?; |
| 667 | 905 | ||
| 668 | create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?; | 906 | // create proposal branch |
| 669 | // add appended commit to local branch | 907 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); |
| 670 | std::fs::write(test_repo.dir.join("appended.md"), "some content")?; | 908 | p.expect("fetching updates...\r\n")?; |
| 671 | test_repo.stage_and_commit("appended commit")?; | 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 | |||
| 933 | // add another commit (so we have a local branch 1 ahead) | ||
| 934 | std::fs::write(test_repo.dir.join("ammended-commit.md"), "some content")?; | ||
| 935 | test_repo.stage_and_commit("add ammended-commit.md")?; | ||
| 936 | test_repo.checkout("main")?; | ||
| 672 | 937 | ||
| 938 | // run test | ||
| 673 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); | 939 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); |
| 674 | p.expect("fetching updates...\r\n")?; | 940 | p.expect("fetching updates...\r\n")?; |
| 675 | p.expect_eventually("\r\n")?; // some updates listed here | 941 | p.expect_eventually("\r\n")?; // some updates listed here |
| @@ -701,7 +967,10 @@ mod when_branch_is_checked_out { | |||
| 701 | async fn didnt_overwrite_local_appendments() -> Result<()> { | 967 | async fn didnt_overwrite_local_appendments() -> Result<()> { |
| 702 | let (originating_repo, test_repo) = prep_and_run().await?; | 968 | let (originating_repo, test_repo) = prep_and_run().await?; |
| 703 | assert_ne!( | 969 | assert_ne!( |
| 704 | test_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, | 970 | test_repo.get_tip_of_local_branch(&get_proposal_branch_name( |
| 971 | &test_repo, | ||
| 972 | FEATURE_BRANCH_NAME_1 | ||
| 973 | )?)?, | ||
| 705 | originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, | 974 | originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, |
| 706 | ); | 975 | ); |
| 707 | Ok(()) | 976 | Ok(()) |
| @@ -737,6 +1006,36 @@ mod when_branch_is_checked_out { | |||
| 737 | tokio::task::spawn_blocking(move || { | 1006 | tokio::task::spawn_blocking(move || { |
| 738 | // create 3 proposals | 1007 | // create 3 proposals |
| 739 | let _ = cli_tester_create_proposals()?; | 1008 | let _ = cli_tester_create_proposals()?; |
| 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 | |||
| 740 | // get proposal id of first | 1039 | // get proposal id of first |
| 741 | let client = Client::default(); | 1040 | let client = Client::default(); |
| 742 | Handle::current().block_on(client.add_relay("ws://localhost:8055"))?; | 1041 | Handle::current().block_on(client.add_relay("ws://localhost:8055"))?; |
| @@ -780,10 +1079,6 @@ mod when_branch_is_checked_out { | |||
| 780 | Some(proposal_1_id.to_string()), | 1079 | Some(proposal_1_id.to_string()), |
| 781 | )?; | 1080 | )?; |
| 782 | 1081 | ||
| 783 | // pretend we have downloaded the origianl version of the first proposal | ||
| 784 | let test_repo = GitTestRepo::default(); | ||
| 785 | test_repo.populate()?; | ||
| 786 | create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?; | ||
| 787 | // pretend we have pulled the updated main branch | 1082 | // pretend we have pulled the updated main branch |
| 788 | test_repo.checkout("main")?; | 1083 | test_repo.checkout("main")?; |
| 789 | std::fs::write(test_repo.dir.join("amazing.md"), "some content")?; | 1084 | std::fs::write(test_repo.dir.join("amazing.md"), "some content")?; |
| @@ -838,6 +1133,36 @@ mod when_branch_is_checked_out { | |||
| 838 | move || { | 1133 | move || { |
| 839 | // create 3 proposals | 1134 | // create 3 proposals |
| 840 | let _ = cli_tester_create_proposals()?; | 1135 | let _ = cli_tester_create_proposals()?; |
| 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 | |||
| 841 | // get proposal id of first | 1166 | // get proposal id of first |
| 842 | let client = Client::default(); | 1167 | let client = Client::default(); |
| 843 | Handle::current().block_on(client.add_relay("ws://localhost:8055"))?; | 1168 | Handle::current().block_on(client.add_relay("ws://localhost:8055"))?; |
| @@ -882,10 +1207,6 @@ mod when_branch_is_checked_out { | |||
| 882 | Some(proposal_1_id.to_string()), | 1207 | Some(proposal_1_id.to_string()), |
| 883 | )?; | 1208 | )?; |
| 884 | 1209 | ||
| 885 | // pretend we have downloaded the origianl version of the first proposal | ||
| 886 | let test_repo = GitTestRepo::default(); | ||
| 887 | test_repo.populate()?; | ||
| 888 | create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?; | ||
| 889 | // pretend we have pulled the updated main branch | 1210 | // pretend we have pulled the updated main branch |
| 890 | test_repo.checkout("main")?; | 1211 | test_repo.checkout("main")?; |
| 891 | std::fs::write(test_repo.dir.join("amazing.md"), "some content")?; | 1212 | std::fs::write(test_repo.dir.join("amazing.md"), "some content")?; |
| @@ -923,7 +1244,10 @@ mod when_branch_is_checked_out { | |||
| 923 | let (originating_repo, test_repo) = prep_and_run().await?; | 1244 | let (originating_repo, test_repo) = prep_and_run().await?; |
| 924 | assert_eq!( | 1245 | assert_eq!( |
| 925 | originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, | 1246 | originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, |
| 926 | test_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, | 1247 | test_repo.get_tip_of_local_branch(&get_proposal_branch_name( |
| 1248 | &test_repo, | ||
| 1249 | FEATURE_BRANCH_NAME_1 | ||
| 1250 | )?)?, | ||
| 927 | ); | 1251 | ); |
| 928 | Ok(()) | 1252 | Ok(()) |
| 929 | } | 1253 | } |