Integration tests for async functions

My crate contain some functions with async implementation

For example, this one implement Gio::InputStream::read_bytes_async. In fact, this function sync, where async is backend only, but I can't get the result from callback anyway (for test assertion)

Seems, I cant test it with tokio as development dependency, but not sure that's correct.
Maybe some native / std features available for examples above?

Thanks

While this function is "asyncronous" in the common sense, it is not an async fn, and it does not return a Future.

I would recommend using a move closure that takes one end of a channel, then sending the argument through that channel.

after calling the function, recv from the other end of the channel, then perform the desired assertions on the received value.

1 Like