From ab1450c655f7fdfc214e1556d16fc754ca684613 Mon Sep 17 00:00:00 2001 From: jk Date: Wed, 31 Jan 2024 15:13:52 +0100 Subject: 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 --- tests/pull.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'tests/pull.rs') diff --git a/tests/pull.rs b/tests/pull.rs index 9b88cb5..92d0ba9 100644 --- a/tests/pull.rs +++ b/tests/pull.rs @@ -144,10 +144,10 @@ mod when_main_is_checked_out { Ok(()) } - #[test] + #[tokio::test] #[serial] - fn cli_show_error() -> Result<()> { - futures::executor::block_on(run_async_cli_show_error()) + async fn cli_show_error() -> Result<()> { + run_async_cli_show_error().await } } } @@ -209,10 +209,10 @@ mod when_branch_doesnt_exist { Ok(()) } - #[test] + #[tokio::test] #[serial] - fn cli_show_error() -> Result<()> { - futures::executor::block_on(run_async_cli_show_error()) + async fn cli_show_error() -> Result<()> { + run_async_cli_show_error().await } } } @@ -274,10 +274,10 @@ mod when_branch_is_checked_out { Ok(()) } - #[test] + #[tokio::test] #[serial] - fn cli_show_up_to_date() -> Result<()> { - futures::executor::block_on(run_async_cli_show_up_to_date()) + async fn cli_show_up_to_date() -> Result<()> { + run_async_cli_show_up_to_date().await } } } @@ -389,17 +389,17 @@ mod when_branch_is_checked_out { Ok(()) } - #[test] + #[tokio::test] #[serial] - fn cli_applied_1_commit() -> Result<()> { - futures::executor::block_on(run_async_cli_applied_1_commit()) + async fn cli_applied_1_commit() -> Result<()> { + run_async_cli_applied_1_commit().await } } - #[test] + #[tokio::test] #[serial] - fn pr_branch_tip_is_most_recent_patch() -> Result<()> { - let (originating_repo, test_repo) = futures::executor::block_on(prep_and_run())?; + async fn pr_branch_tip_is_most_recent_patch() -> Result<()> { + let (originating_repo, test_repo) = prep_and_run().await?; assert_eq!( originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, test_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, -- cgit v1.2.3