test(tui): add test for tui entry point

This commit is contained in:
Orhun Parmaksız 2022-02-02 03:11:14 +03:00
parent 1dc3f6ea05
commit e6d018ee44
No known key found for this signature in database
GPG key ID: F83424824B3E4B90
2 changed files with 21 additions and 1 deletions

View file

@ -71,10 +71,30 @@ pub fn run<Output: Write>(args: Args, output: Output) -> Result<()> {
let command = Command::parse(key, app.is_input_mode());
app.run_command(command)?;
}
#[cfg(not(test))]
Event::Tick => {
app.tick();
}
#[cfg(test)]
Event::Tick => {
app.running = false;
}
}
}
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_systeroid_tui() -> Result<()> {
let args = Args {
tick_rate: 1000,
..Args::default()
};
run(args, &mut Vec::new())?;
Ok(())
}
}

View file

@ -28,7 +28,7 @@ fn assert_buffer(mut buffer: Buffer, backend: &TestBackend) -> Result<()> {
}
#[test]
fn test_tui() -> Result<()> {
fn test_render_tui() -> Result<()> {
let mut sysctl = Sysctl {
parameters: vec![
Parameter {