From d425dbe203c17166e2e0b5692695448f0cb85513 Mon Sep 17 00:00:00 2001 From: mo8it Date: Wed, 1 May 2024 18:08:18 +0200 Subject: [PATCH] Test run_cmd --- src/cmd.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/cmd.rs b/src/cmd.rs index e4bc112..9762cf8 100644 --- a/src/cmd.rs +++ b/src/cmd.rs @@ -75,3 +75,19 @@ impl<'a> CargoCmd<'a> { run_cmd(cmd, self.description, self.output) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_run_cmd() { + let mut cmd = Command::new("echo"); + cmd.arg("Hello"); + + let mut output = Vec::with_capacity(8); + run_cmd(cmd, "echo …", &mut output).unwrap(); + + assert_eq!(output, b"Hello\n\n"); + } +}