diff options
| author | jk <email@jkrause.io> | 2024-01-31 15:13:52 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-02-02 07:21:01 +0000 |
| commit | ab1450c655f7fdfc214e1556d16fc754ca684613 (patch) | |
| tree | 9ded305354a272d411059493e9475a3e39ff5cae /tests/prs_list.rs | |
| parent | ccdbc337ae16d7c70be44166269c8b2d5b9f5c09 (diff) | |
test: replace block_on with tokio::tests
This is intended to improve the reliabilty of the tests. there have been
particular issues with random tests never ending when run in the nix
configuration
see discussion here
https://github.com/DanConwayDev/ngit-cli/issues/
6#issuecomment-1918971239
and:
https://github.com/DanConwayDev/ngit-cli/pull/7
Diffstat (limited to 'tests/prs_list.rs')
| -rw-r--r-- | tests/prs_list.rs | 85 |
1 files changed, 43 insertions, 42 deletions
diff --git a/tests/prs_list.rs b/tests/prs_list.rs index 7f753c0..75704f6 100644 --- a/tests/prs_list.rs +++ b/tests/prs_list.rs | |||
| @@ -226,17 +226,18 @@ mod when_main_branch_is_uptodate { | |||
| 226 | Ok(()) | 226 | Ok(()) |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | #[test] | 229 | #[tokio::test] |
| 230 | #[serial] | 230 | #[serial] |
| 231 | fn prompts_to_choose_from_pr_titles() -> Result<()> { | 231 | async fn prompts_to_choose_from_pr_titles() -> Result<()> { |
| 232 | futures::executor::block_on(run_async_prompts_to_choose_from_pr_titles()) | 232 | let _ = run_async_prompts_to_choose_from_pr_titles().await; |
| 233 | Ok(()) | ||
| 233 | } | 234 | } |
| 234 | } | 235 | } |
| 235 | 236 | ||
| 236 | #[test] | 237 | #[tokio::test] |
| 237 | #[serial] | 238 | #[serial] |
| 238 | fn pr_branch_created_with_correct_name() -> Result<()> { | 239 | async fn pr_branch_created_with_correct_name() -> Result<()> { |
| 239 | let (_, test_repo) = futures::executor::block_on(prep_and_run())?; | 240 | let (_, test_repo) = prep_and_run().await?; |
| 240 | assert_eq!( | 241 | assert_eq!( |
| 241 | vec![FEATURE_BRANCH_NAME_1, "main"], | 242 | vec![FEATURE_BRANCH_NAME_1, "main"], |
| 242 | test_repo.get_local_branch_names()? | 243 | test_repo.get_local_branch_names()? |
| @@ -244,10 +245,10 @@ mod when_main_branch_is_uptodate { | |||
| 244 | Ok(()) | 245 | Ok(()) |
| 245 | } | 246 | } |
| 246 | 247 | ||
| 247 | #[test] | 248 | #[tokio::test] |
| 248 | #[serial] | 249 | #[serial] |
| 249 | fn pr_branch_checked_out() -> Result<()> { | 250 | async fn pr_branch_checked_out() -> Result<()> { |
| 250 | let (_, test_repo) = futures::executor::block_on(prep_and_run())?; | 251 | let (_, test_repo) = prep_and_run().await?; |
| 251 | assert_eq!( | 252 | assert_eq!( |
| 252 | FEATURE_BRANCH_NAME_1, | 253 | FEATURE_BRANCH_NAME_1, |
| 253 | test_repo.get_checked_out_branch_name()?, | 254 | test_repo.get_checked_out_branch_name()?, |
| @@ -255,11 +256,10 @@ mod when_main_branch_is_uptodate { | |||
| 255 | Ok(()) | 256 | Ok(()) |
| 256 | } | 257 | } |
| 257 | 258 | ||
| 258 | #[test] | 259 | #[tokio::test] |
| 259 | #[serial] | 260 | #[serial] |
| 260 | fn pr_branch_tip_is_most_recent_patch() -> Result<()> { | 261 | async fn pr_branch_tip_is_most_recent_patch() -> Result<()> { |
| 261 | let (originating_repo, test_repo) = | 262 | let (originating_repo, test_repo) = prep_and_run().await?; |
| 262 | futures::executor::block_on(prep_and_run())?; | ||
| 263 | assert_eq!( | 263 | assert_eq!( |
| 264 | originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, | 264 | originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, |
| 265 | test_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, | 265 | test_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, |
| @@ -391,17 +391,18 @@ mod when_main_branch_is_uptodate { | |||
| 391 | Ok(()) | 391 | Ok(()) |
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | #[test] | 394 | #[tokio::test] |
| 395 | #[serial] | 395 | #[serial] |
| 396 | fn prompts_to_choose_from_pr_titles() -> Result<()> { | 396 | async fn prompts_to_choose_from_pr_titles() -> Result<()> { |
| 397 | futures::executor::block_on(run_async_prompts_to_choose_from_pr_titles()) | 397 | let _ = run_async_prompts_to_choose_from_pr_titles().await; |
| 398 | Ok(()) | ||
| 398 | } | 399 | } |
| 399 | } | 400 | } |
| 400 | 401 | ||
| 401 | #[test] | 402 | #[tokio::test] |
| 402 | #[serial] | 403 | #[serial] |
| 403 | fn pr_branch_created_with_correct_name() -> Result<()> { | 404 | async fn pr_branch_created_with_correct_name() -> Result<()> { |
| 404 | let (_, test_repo) = futures::executor::block_on(prep_and_run())?; | 405 | let (_, test_repo) = prep_and_run().await?; |
| 405 | assert_eq!( | 406 | assert_eq!( |
| 406 | vec![FEATURE_BRANCH_NAME_3, "main"], | 407 | vec![FEATURE_BRANCH_NAME_3, "main"], |
| 407 | test_repo.get_local_branch_names()? | 408 | test_repo.get_local_branch_names()? |
| @@ -409,10 +410,10 @@ mod when_main_branch_is_uptodate { | |||
| 409 | Ok(()) | 410 | Ok(()) |
| 410 | } | 411 | } |
| 411 | 412 | ||
| 412 | #[test] | 413 | #[tokio::test] |
| 413 | #[serial] | 414 | #[serial] |
| 414 | fn pr_branch_checked_out() -> Result<()> { | 415 | async fn pr_branch_checked_out() -> Result<()> { |
| 415 | let (_, test_repo) = futures::executor::block_on(prep_and_run())?; | 416 | let (_, test_repo) = prep_and_run().await?; |
| 416 | assert_eq!( | 417 | assert_eq!( |
| 417 | FEATURE_BRANCH_NAME_3, | 418 | FEATURE_BRANCH_NAME_3, |
| 418 | test_repo.get_checked_out_branch_name()?, | 419 | test_repo.get_checked_out_branch_name()?, |
| @@ -420,11 +421,10 @@ mod when_main_branch_is_uptodate { | |||
| 420 | Ok(()) | 421 | Ok(()) |
| 421 | } | 422 | } |
| 422 | 423 | ||
| 423 | #[test] | 424 | #[tokio::test] |
| 424 | #[serial] | 425 | #[serial] |
| 425 | fn pr_branch_tip_is_most_recent_patch() -> Result<()> { | 426 | async fn pr_branch_tip_is_most_recent_patch() -> Result<()> { |
| 426 | let (originating_repo, test_repo) = | 427 | let (originating_repo, test_repo) = prep_and_run().await?; |
| 427 | futures::executor::block_on(prep_and_run())?; | ||
| 428 | assert_eq!( | 428 | assert_eq!( |
| 429 | originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_3)?, | 429 | originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_3)?, |
| 430 | test_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_3)?, | 430 | test_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_3)?, |
| @@ -579,17 +579,18 @@ mod when_main_branch_is_uptodate { | |||
| 579 | Ok(()) | 579 | Ok(()) |
| 580 | } | 580 | } |
| 581 | 581 | ||
| 582 | #[test] | 582 | #[tokio::test] |
| 583 | #[serial] | 583 | #[serial] |
| 584 | fn prompts_to_choose_from_pr_titles() -> Result<()> { | 584 | async fn prompts_to_choose_from_pr_titles() -> Result<()> { |
| 585 | futures::executor::block_on(run_async_prompts_to_choose_from_pr_titles()) | 585 | let _ = run_async_prompts_to_choose_from_pr_titles().await; |
| 586 | Ok(()) | ||
| 586 | } | 587 | } |
| 587 | } | 588 | } |
| 588 | 589 | ||
| 589 | #[test] | 590 | #[tokio::test] |
| 590 | #[serial] | 591 | #[serial] |
| 591 | fn pr_branch_checked_out() -> Result<()> { | 592 | async fn pr_branch_checked_out() -> Result<()> { |
| 592 | let (_, test_repo) = futures::executor::block_on(prep_and_run())?; | 593 | let (_, test_repo) = prep_and_run().await?; |
| 593 | assert_eq!( | 594 | assert_eq!( |
| 594 | FEATURE_BRANCH_NAME_1, | 595 | FEATURE_BRANCH_NAME_1, |
| 595 | test_repo.get_checked_out_branch_name()?, | 596 | test_repo.get_checked_out_branch_name()?, |
| @@ -738,17 +739,18 @@ mod when_main_branch_is_uptodate { | |||
| 738 | Ok(()) | 739 | Ok(()) |
| 739 | } | 740 | } |
| 740 | 741 | ||
| 741 | #[test] | 742 | #[tokio::test] |
| 742 | #[serial] | 743 | #[serial] |
| 743 | fn prompts_to_choose_from_pr_titles() -> Result<()> { | 744 | async fn prompts_to_choose_from_pr_titles() -> Result<()> { |
| 744 | futures::executor::block_on(run_async_prompts_to_choose_from_pr_titles()) | 745 | let _ = run_async_prompts_to_choose_from_pr_titles().await; |
| 746 | Ok(()) | ||
| 745 | } | 747 | } |
| 746 | } | 748 | } |
| 747 | 749 | ||
| 748 | #[test] | 750 | #[tokio::test] |
| 749 | #[serial] | 751 | #[serial] |
| 750 | fn pr_branch_checked_out() -> Result<()> { | 752 | async fn pr_branch_checked_out() -> Result<()> { |
| 751 | let (_, test_repo) = futures::executor::block_on(prep_and_run())?; | 753 | let (_, test_repo) = prep_and_run().await?; |
| 752 | assert_eq!( | 754 | assert_eq!( |
| 753 | FEATURE_BRANCH_NAME_1, | 755 | FEATURE_BRANCH_NAME_1, |
| 754 | test_repo.get_checked_out_branch_name()?, | 756 | test_repo.get_checked_out_branch_name()?, |
| @@ -756,11 +758,10 @@ mod when_main_branch_is_uptodate { | |||
| 756 | Ok(()) | 758 | Ok(()) |
| 757 | } | 759 | } |
| 758 | 760 | ||
| 759 | #[test] | 761 | #[tokio::test] |
| 760 | #[serial] | 762 | #[serial] |
| 761 | fn pr_branch_tip_is_most_recent_patch() -> Result<()> { | 763 | async fn pr_branch_tip_is_most_recent_patch() -> Result<()> { |
| 762 | let (originating_repo, test_repo) = | 764 | let (originating_repo, test_repo) = prep_and_run().await?; |
| 763 | futures::executor::block_on(prep_and_run())?; | ||
| 764 | assert_eq!( | 765 | assert_eq!( |
| 765 | originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, | 766 | originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, |
| 766 | test_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, | 767 | test_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, |