Crates.io | safina-async-test |
lib.rs | safina-async-test |
version | 0.1.14 |
source | src |
created_at | 2020-12-02 13:09:01.781996 |
updated_at | 2024-10-27 23:49:46.256094 |
description | Macro for running async tests - ARCHIVED: Code moved to `safina` crate. |
homepage | |
repository | https://gitlab.com/leonhard-llc/safina-rs |
max_upload_size | |
id | 318884 |
size | 11,506 |
This crate is archived and will not be updated.
The macro is now at
safina::async_test
in the
safina
crate.
An async_test
macro for running async fn
tests.
It is part of safina
, a safe async runtime.
safina_executor
safina_timer::start_timer_thread
before running the testforbid(unsafe_code)
stable
requires once_cell
crate which contains some unsafe code.
This is necessary until
std::lazy::OnceCell
is stable.use safina_async_test::async_test;
#[async_test]
async fn test1() {
async_work().await.unwrap();
}
use safina_async_test::async_test;
// Make your test an `async fn`.
#[async_test]
async fn test2() {
// You can `await`.
async_work().await.unwrap();
// You can spawn tasks which will run on
// the executor.
// These tasks stop when the test
// function returns and drops the
// executor.
safina_executor::spawn(background_task());
// You can run blocking code without
// stalling other async tasks.
let result = safina_executor::schedule_blocking(
|| blocking_work()
).async_recv().await.unwrap();
assert_eq!(3, result.unwrap());
// You can use timer functions.
safina_timer::sleep_for(
Duration::from_millis(10)).await;
safina_timer::with_timeout(
async_work(),
Duration::from_millis(100)
).await.unwrap();
}
https://docs.rs/safina-async-test
safina-executor
v0.3.1.safina-executor
v0.3.0.safina-executor
v0.2.0.safina-executor
and
safina-timer
crates.once_cell
.safina-timer
threadsafina-executor
v0.1.3 APIsafina-executor
version which removes need for Box::pin
.safina
package to
safina-executor
.Cargo.toml
and bump version number../release.sh