summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGreg <gregory.mkv@gmail.com>2019-11-18 23:12:03 -0500
committerGreg <gregory.mkv@gmail.com>2019-11-18 23:12:03 -0500
commit03a10c158a59d4c121a438d87a335a7b208ffc0f (patch)
tree792b8c3861605a07f3887da1e6813ab081610f7d /tests
parentd13899dbf3001470636595d69fc6bfd504542c0b (diff)
Update and trim some deps
Diffstat (limited to 'tests')
-rw-r--r--tests/cli.rs25
1 files changed, 14 insertions, 11 deletions
diff --git a/tests/cli.rs b/tests/cli.rs
index 39aab05..20934b8 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -1,29 +1,32 @@
use anyhow::Result;
use assert_cmd::prelude::*;
-use assert_fs::prelude::*;
-use std::process::Command;
+use std::{io::prelude::*, process::Command};
fn sd() -> Command {
Command::cargo_bin(env!("CARGO_PKG_NAME")).expect("Error invoking sd")
}
+fn assert_file(path: &std::path::Path, content: &str) {
+ assert_eq!(content, std::fs::read_to_string(path).unwrap());
+}
+
#[test]
fn in_place() -> Result<()> {
- let file = assert_fs::NamedTempFile::new("test")?;
- file.write_str("abc123def")?;
+ let mut file = tempfile::NamedTempFile::new()?;
+ file.write(b"abc123def")?;
- let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME"))?;
- cmd.args(&["abc\\d+", "", file.path().to_str().unwrap()]);
- cmd.assert().success();
- file.assert("def");
+ sd().args(&["abc\\d+", "", file.path().to_str().unwrap()])
+ .assert()
+ .success();
+ assert_file(file.path(), "def");
Ok(())
}
#[test]
fn replace_into_stdout() -> Result<()> {
- let file = assert_fs::NamedTempFile::new("test")?;
- file.write_str("abc123def")?;
+ let mut file = tempfile::NamedTempFile::new()?;
+ file.write(b"abc123def")?;
#[rustfmt::skip]
sd()
@@ -32,7 +35,7 @@ fn replace_into_stdout() -> Result<()> {
.success()
.stdout("def");
- file.assert("abc123def");
+ assert_file(file.path(), "abc123def");
Ok(())
}