When I modified the code to use your example I also get:
Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.
I am testing these function with two different unit test methods, one with the attribute #[test]
and one with the attribute #[tokio::test]
This is to ensure that foo_sync
will operate correctly in with an existing tokio runtime or without a tokio runtime being started. In my case, foo_sync
is a low-level library function and it will be used in higher level applications, where some are async applications and some are traditional synchronous applications.