diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/push.rs | 170 |
1 files changed, 165 insertions, 5 deletions
diff --git a/tests/push.rs b/tests/push.rs index d1ad0e6..81daf0e 100644 --- a/tests/push.rs +++ b/tests/push.rs | |||
| @@ -243,7 +243,7 @@ mod when_branch_is_checked_out { | |||
| 243 | 243 | ||
| 244 | mod cli_prompts { | 244 | mod cli_prompts { |
| 245 | use super::*; | 245 | use super::*; |
| 246 | async fn run_async_cli_show_up_to_date() -> Result<()> { | 246 | async fn run_async_cli_shows_proposal_ahead_error() -> Result<()> { |
| 247 | let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( | 247 | let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( |
| 248 | Relay::new(8051, None, None), | 248 | Relay::new(8051, None, None), |
| 249 | Relay::new(8052, None, None), | 249 | Relay::new(8052, None, None), |
| @@ -294,8 +294,8 @@ mod when_branch_is_checked_out { | |||
| 294 | 294 | ||
| 295 | #[tokio::test] | 295 | #[tokio::test] |
| 296 | #[serial] | 296 | #[serial] |
| 297 | async fn cli_show_up_to_date() -> Result<()> { | 297 | async fn cli_show_proposal_ahead_error() -> Result<()> { |
| 298 | let _ = run_async_cli_show_up_to_date().await; | 298 | let _ = run_async_cli_shows_proposal_ahead_error().await; |
| 299 | Ok(()) | 299 | Ok(()) |
| 300 | } | 300 | } |
| 301 | } | 301 | } |
| @@ -476,7 +476,167 @@ mod when_branch_is_checked_out { | |||
| 476 | } | 476 | } |
| 477 | 477 | ||
| 478 | mod when_branch_has_been_rebased { | 478 | mod when_branch_has_been_rebased { |
| 479 | // use super::*; | 479 | use super::*; |
| 480 | // TODO | 480 | |
| 481 | mod cli_prompts { | ||
| 482 | use super::*; | ||
| 483 | async fn run_async_cli_shows_unpublished_rebase_error() -> Result<()> { | ||
| 484 | let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( | ||
| 485 | Relay::new(8051, None, None), | ||
| 486 | Relay::new(8052, None, None), | ||
| 487 | Relay::new(8053, None, None), | ||
| 488 | Relay::new(8055, None, None), | ||
| 489 | Relay::new(8056, None, None), | ||
| 490 | ); | ||
| 491 | |||
| 492 | r51.events.push(generate_test_key_1_relay_list_event()); | ||
| 493 | r51.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 494 | r51.events.push(generate_repo_ref_event()); | ||
| 495 | |||
| 496 | r55.events.push(generate_repo_ref_event()); | ||
| 497 | r55.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 498 | r55.events.push(generate_test_key_1_relay_list_event()); | ||
| 499 | |||
| 500 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | ||
| 501 | cli_tester_create_proposals()?; | ||
| 502 | |||
| 503 | let test_repo = GitTestRepo::default(); | ||
| 504 | test_repo.populate()?; | ||
| 505 | |||
| 506 | // simulate rebase | ||
| 507 | std::fs::write(test_repo.dir.join("amazing.md"), "some content")?; | ||
| 508 | test_repo.stage_and_commit("commit for rebasing on top of")?; | ||
| 509 | create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", true)?; | ||
| 510 | |||
| 511 | let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]); | ||
| 512 | // p.expect_end_eventually_and_print()?; | ||
| 513 | |||
| 514 | p.expect("finding proposal root event...\r\n")?; | ||
| 515 | p.expect("found proposal root event. finding commits...\r\n")?; | ||
| 516 | p.expect("Error: local unpublished proposal has been rebased. consider force pushing\r\n")?; | ||
| 517 | p.expect_end()?; | ||
| 518 | |||
| 519 | for p in [51, 52, 53, 55, 56] { | ||
| 520 | relay::shutdown_relay(8000 + p)?; | ||
| 521 | } | ||
| 522 | Ok(()) | ||
| 523 | }); | ||
| 524 | |||
| 525 | // launch relay | ||
| 526 | let _ = join!( | ||
| 527 | r51.listen_until_close(), | ||
| 528 | r52.listen_until_close(), | ||
| 529 | r53.listen_until_close(), | ||
| 530 | r55.listen_until_close(), | ||
| 531 | r56.listen_until_close(), | ||
| 532 | ); | ||
| 533 | cli_tester_handle.join().unwrap()?; | ||
| 534 | Ok(()) | ||
| 535 | } | ||
| 536 | |||
| 537 | #[tokio::test] | ||
| 538 | #[serial] | ||
| 539 | async fn cli_shows_unpublished_rebase_error() -> Result<()> { | ||
| 540 | let _ = run_async_cli_shows_unpublished_rebase_error().await; | ||
| 541 | Ok(()) | ||
| 542 | } | ||
| 543 | } | ||
| 544 | mod with_force_flag { | ||
| 545 | use super::*; | ||
| 546 | |||
| 547 | mod cli_prompts { | ||
| 548 | use super::*; | ||
| 549 | async fn run_async_cli_shows_revision_sent() -> Result<()> { | ||
| 550 | let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( | ||
| 551 | Relay::new(8051, None, None), | ||
| 552 | Relay::new(8052, None, None), | ||
| 553 | Relay::new(8053, None, None), | ||
| 554 | Relay::new(8055, None, None), | ||
| 555 | Relay::new(8056, None, None), | ||
| 556 | ); | ||
| 557 | |||
| 558 | r51.events.push(generate_test_key_1_relay_list_event()); | ||
| 559 | r51.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 560 | r51.events.push(generate_repo_ref_event()); | ||
| 561 | |||
| 562 | r55.events.push(generate_repo_ref_event()); | ||
| 563 | r55.events.push(generate_test_key_1_metadata_event("fred")); | ||
| 564 | r55.events.push(generate_test_key_1_relay_list_event()); | ||
| 565 | |||
| 566 | let cli_tester_handle = std::thread::spawn(move || -> Result<()> { | ||
| 567 | cli_tester_create_proposals()?; | ||
| 568 | |||
| 569 | let test_repo = GitTestRepo::default(); | ||
| 570 | test_repo.populate()?; | ||
| 571 | |||
| 572 | // simulate rebase | ||
| 573 | std::fs::write(test_repo.dir.join("amazing.md"), "some content")?; | ||
| 574 | test_repo.stage_and_commit("commit for rebasing on top of")?; | ||
| 575 | create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?; | ||
| 576 | let mut p = CliTester::new_from_dir( | ||
| 577 | &test_repo.dir, | ||
| 578 | [ | ||
| 579 | "--nsec", | ||
| 580 | TEST_KEY_1_NSEC, | ||
| 581 | "--password", | ||
| 582 | TEST_PASSWORD, | ||
| 583 | "--disable-cli-spinners", | ||
| 584 | "push", | ||
| 585 | "--force", | ||
| 586 | "--no-cover-letter", | ||
| 587 | ], | ||
| 588 | ); | ||
| 589 | p.expect("finding proposal root event...\r\n")?; | ||
| 590 | p.expect("found proposal root event. finding commits...\r\n")?; | ||
| 591 | p.expect("preparing to force push proposal revision...\r\n")?; | ||
| 592 | |||
| 593 | // standard output from `ngit send` | ||
| 594 | p.expect("creating patch for 2 commits from 'head' that can be merged into 'main'\r\n")?; | ||
| 595 | p.expect("searching for profile and relay updates...\r\n")?; | ||
| 596 | p.expect("\r")?; | ||
| 597 | p.expect("logged in as fred\r\n")?; | ||
| 598 | p.expect("posting 2 patches without a covering letter...\r\n")?; | ||
| 599 | |||
| 600 | relay::expect_send_with_progress( | ||
| 601 | &mut p, | ||
| 602 | vec![ | ||
| 603 | (" [my-relay] [repo-relay] ws://localhost:8055", true, ""), | ||
| 604 | (" [my-relay] ws://localhost:8053", true, ""), | ||
| 605 | (" [repo-relay] ws://localhost:8056", true, ""), | ||
| 606 | (" [default] ws://localhost:8051", true, ""), | ||
| 607 | (" [default] ws://localhost:8052", true, ""), | ||
| 608 | ], | ||
| 609 | 2, | ||
| 610 | )?; | ||
| 611 | // end standard `ngit send output` | ||
| 612 | p.expect_after_whitespace("force pushed proposal revision\r\n")?; | ||
| 613 | p.expect_end()?; | ||
| 614 | |||
| 615 | for p in [51, 52, 53, 55, 56] { | ||
| 616 | relay::shutdown_relay(8000 + p)?; | ||
| 617 | } | ||
| 618 | Ok(()) | ||
| 619 | }); | ||
| 620 | |||
| 621 | // launch relay | ||
| 622 | let _ = join!( | ||
| 623 | r51.listen_until_close(), | ||
| 624 | r52.listen_until_close(), | ||
| 625 | r53.listen_until_close(), | ||
| 626 | r55.listen_until_close(), | ||
| 627 | r56.listen_until_close(), | ||
| 628 | ); | ||
| 629 | cli_tester_handle.join().unwrap()?; | ||
| 630 | Ok(()) | ||
| 631 | } | ||
| 632 | |||
| 633 | #[tokio::test] | ||
| 634 | #[serial] | ||
| 635 | async fn cli_shows_revision_sent() -> Result<()> { | ||
| 636 | let _ = run_async_cli_shows_revision_sent().await; | ||
| 637 | Ok(()) | ||
| 638 | } | ||
| 639 | } | ||
| 640 | } | ||
| 481 | } | 641 | } |
| 482 | } | 642 | } |