Skip to content

Writing unit tests for Rust side #328

Closed Answered by temeddix
TheTharin asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @TheTharin :)

For the first problem, I suggest you to sleep for some time after sending the signal so that tokio runtime and its event loop can keep alive for some more time, allowing the receiver to receive the signal.

use crate::messages::dialogue::DialogueRequest;

pub async fn test_receiver(number: i8) {
    let mut receiver = DialogueRequest::get_dart_signal_receiver();

    println!("Test receiver number is {}", number);

    while let Some(_dart_signal) = receiver.recv().await {
        println!("Test receiver number is {}", number + 100);
    }
}

#[cfg(test)]
mod tests {
    use std::{cell::RefCell, sync::Mutex};

    use crate::messages::dialogue::DIALOGUE_REQUEST_SENDER;

    

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@TheTharin
Comment options

@temeddix
Comment options

@TheTharin
Comment options

Answer selected by TheTharin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants