-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add assert_cmd and predicated to dev deps (#2)
* Add assert_cmd and predicated to dev deps * Add e2e testing
- Loading branch information
1 parent
5fcbf62
commit 487d7ad
Showing
5 changed files
with
222 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use assert_cmd::prelude::*; | ||
use predicates::prelude::*; | ||
use std::process::Command; | ||
|
||
#[test] | ||
fn fakes_commands() -> Result<(), Box<dyn std::error::Error>> { | ||
let mut cmd = Command::cargo_bin("fakemall")?; | ||
|
||
cmd.arg("exec") | ||
.arg("tests/test_config.toml") | ||
.arg("dmidecode"); | ||
cmd.assert() | ||
.success() | ||
.stdout(predicate::str::contains("this is a sample output")); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn set_doesnt_exist() -> Result<(), Box<dyn std::error::Error>> { | ||
let mut cmd = Command::cargo_bin("fakemall")?; | ||
|
||
cmd.arg("exec").arg("test/file/doesnt/exist").arg("kekw"); | ||
cmd.assert() | ||
.failure() | ||
.stderr(predicate::str::contains("No such file or directory")); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn command_doesnt_exist() -> Result<(), Box<dyn std::error::Error>> { | ||
let mut cmd = Command::cargo_bin("fakemall")?; | ||
|
||
cmd.arg("exec").arg("tests/test_config.toml").arg("asdf"); | ||
cmd.assert() | ||
.failure() | ||
.stdout(predicate::str::contains("asdf: command not found")); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[[commands]] | ||
matches = "dmidecode" | ||
output = "this is a sample output" |