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/push.rs | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'tests/push.rs') diff --git a/tests/push.rs b/tests/push.rs index 4fdb6eb..4af5bd4 100644 --- a/tests/push.rs +++ b/tests/push.rs @@ -111,6 +111,7 @@ mod when_pr_isnt_associated_with_branch_name { use super::*; mod cli_prompts { + use super::*; async fn run_async_cli_show_error() -> Result<()> { let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( @@ -164,10 +165,10 @@ mod when_pr_isnt_associated_with_branch_name { 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 } } } @@ -229,10 +230,11 @@ 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<()> { + let _ = run_async_cli_show_up_to_date().await; + Ok(()) } } } @@ -291,10 +293,11 @@ 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<()> { + let _ = run_async_cli_show_up_to_date().await; + Ok(()) } } } @@ -389,10 +392,11 @@ 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<()> { + let _ = run_async_cli_applied_1_commit().await; + Ok(()) } } @@ -453,10 +457,10 @@ mod when_branch_is_checked_out { Ok((res, r55.events.clone())) } - #[test] + #[tokio::test] #[serial] - fn commits_issued_as_patch_event() -> Result<()> { - let (test_repo, r55_events) = futures::executor::block_on(prep_and_run())?; + async fn commits_issued_as_patch_event() -> Result<()> { + let (test_repo, r55_events) = prep_and_run().await?; let commit_id = test_repo .get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)? -- cgit v1.2.3