summaryrefslogtreecommitdiff
path: root/tests/cli.rs
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-02-24 11:03:52 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-02-24 11:03:52 +0200
commit247d3a720d5fa727db86d0b34c02e9139664dc4e (patch)
tree2a88790d80258b41e4a4aca3f1b223103d8851dc /tests/cli.rs
parentdc314144fdd2ea4f86d7e951770b0763ea22be78 (diff)
Anyhow to simplify tests
Diffstat (limited to 'tests/cli.rs')
-rw-r--r--tests/cli.rs14
1 files changed, 7 insertions, 7 deletions
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<PtySession, Box<dyn Error>> {
+fn spawn_interactive_process() -> Result<PtySession> {
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<dyn Error>> {
+fn expect_prompt(p: &mut PtySession) -> Result<()> {
p.exp_string("> ")?;
Ok(())
}
#[test]
-fn shows_a_prompt() -> Result<(), Box<dyn Error>> {
+fn shows_a_prompt() -> Result<()> {
spawn_interactive_process()?;
Ok(())
}
#[test]
-fn does_nothing_after_receiving_whitespace_input() -> Result<(), Box<dyn Error>> {
+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<dyn Error>>
}
#[test]
-fn quits_when_eof_is_sent() -> Result<(), Box<dyn Error>> {
+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<dyn Error>> {
}
#[test]
-fn quits_when_exit_command_is_sent() -> Result<(), Box<dyn Error>> {
+fn quits_when_exit_command_is_sent() -> Result<()> {
let mut p = spawn_interactive_process()?;
p.send_line("exit")?;
p.exp_eof()?;