aboutsummaryrefslogtreecommitdiff
path: root/tests/cli.rs
diff options
context:
space:
mode:
authorOndřej Čertík <ondrej@certik.us>2020-01-14 13:42:18 -0700
committerOndřej Čertík <ondrej@certik.us>2020-01-14 13:42:18 -0700
commit8539efaf67059ddef23b6221b3fe4fa5bc185004 (patch)
treed4715151d5ad2346cede8af262c50ac207b85fa3 /tests/cli.rs
parent772d16a78abda39f2b3d6d3bb91253835bf0ff99 (diff)
downloadfpm-8539efaf67059ddef23b6221b3fe4fa5bc185004.tar.gz
fpm-8539efaf67059ddef23b6221b3fe4fa5bc185004.zip
Add Rust tests
Diffstat (limited to 'tests/cli.rs')
-rw-r--r--tests/cli.rs49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/cli.rs b/tests/cli.rs
new file mode 100644
index 0000000..09e42e9
--- /dev/null
+++ b/tests/cli.rs
@@ -0,0 +1,49 @@
+use std::process::Command; // Run programs
+use assert_cmd::prelude::*; // Add methods on commands
+use predicates::prelude::*; // Used for writing assertions
+
+#[test]
+fn test_help() {
+ let mut cmd = Command::cargo_bin("fpm").unwrap();
+ cmd.arg("--help");
+ cmd.assert()
+ .success()
+ .stdout(
+ predicate::str::contains("--help Prints help information"));
+}
+
+#[test]
+fn test_1() {
+ let mut build = Command::cargo_bin("fpm").unwrap();
+ build.arg("build")
+ .current_dir("tests/1");
+ build.assert()
+ .success()
+ .stdout(predicate::str::contains("Built target p1")
+ .and(predicate::str::contains("TEST1 OK").not()));
+
+ let mut run = Command::cargo_bin("fpm").unwrap();
+ run.arg("run")
+ .current_dir("tests/1");
+ run.assert()
+ .success()
+ .stdout(predicate::str::contains("TEST1 OK"));
+}
+
+#[test]
+fn test_2() {
+ let mut build = Command::cargo_bin("fpm").unwrap();
+ build.arg("build")
+ .current_dir("tests/2");
+ build.assert()
+ .success()
+ .stdout(predicate::str::contains("Built target p1")
+ .and(predicate::str::contains("TEST2 OK").not()));
+
+ let mut run = Command::cargo_bin("fpm").unwrap();
+ run.arg("run")
+ .current_dir("tests/2");
+ run.assert()
+ .success()
+ .stdout(predicate::str::contains("TEST2 OK"));
+}