From 247d3a720d5fa727db86d0b34c02e9139664dc4e Mon Sep 17 00:00:00 2001 From: Justin Wernick Date: Fri, 24 Feb 2023 11:03:52 +0200 Subject: Anyhow to simplify tests --- tests/cli.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/cli.rs') diff --git a/tests/cli.rs b/tests/cli.rs index ccf837b..8197a92 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -1,27 +1,27 @@ +use anyhow::Result; use assert_cmd::cargo::cargo_bin; use rexpect::{session::PtySession, spawn}; -use std::error::Error; -fn spawn_interactive_process() -> Result> { +fn spawn_interactive_process() -> Result { let path = cargo_bin(env!("CARGO_PKG_NAME")); let mut process = spawn(&path.display().to_string(), Some(3000))?; expect_prompt(&mut process)?; Ok(process) } -fn expect_prompt(p: &mut PtySession) -> Result<(), Box> { +fn expect_prompt(p: &mut PtySession) -> Result<()> { p.exp_string("> ")?; Ok(()) } #[test] -fn shows_a_prompt() -> Result<(), Box> { +fn shows_a_prompt() -> Result<()> { spawn_interactive_process()?; Ok(()) } #[test] -fn does_nothing_after_receiving_whitespace_input() -> Result<(), Box> { +fn does_nothing_after_receiving_whitespace_input() -> Result<()> { let mut p = spawn_interactive_process()?; p.send_line("")?; expect_prompt(&mut p)?; @@ -31,7 +31,7 @@ fn does_nothing_after_receiving_whitespace_input() -> Result<(), Box> } #[test] -fn quits_when_eof_is_sent() -> Result<(), Box> { +fn quits_when_eof_is_sent() -> Result<()> { let mut p = spawn_interactive_process()?; p.send_control('d')?; p.exp_eof()?; @@ -39,7 +39,7 @@ fn quits_when_eof_is_sent() -> Result<(), Box> { } #[test] -fn quits_when_exit_command_is_sent() -> Result<(), Box> { +fn quits_when_exit_command_is_sent() -> Result<()> { let mut p = spawn_interactive_process()?; p.send_line("exit")?; p.exp_eof()?; -- cgit v1.2.3