pub mod output_file {
use assert_cmd::prelude::*;
use predicates::prelude::*;
use std::{fs, process::Command};
#[test]
fn arg_is_none() {
let mut cmd = Command::cargo_bin("artem").unwrap();
cmd.arg("assets/images/standard_test_img.png").arg("-o");
cmd.assert().failure().stderr(predicate::str::starts_with(
"error: a value is required for '--output <output-file>' but none was supplied",
));
}
#[test]
#[cfg(not(target_os = "windows"))]
fn file_is_ansi() {
let mut cmd = Command::cargo_bin("artem").unwrap();
cmd.arg("assets/images/standard_test_img.png")
.args(["-o", "/tmp/ascii.ans"]);
cmd.assert().success().stdout(predicate::str::starts_with(
"Written 2105 bytes to /tmp/ascii.ans",
));
fs::remove_file("/tmp/ascii.ans").unwrap();
}
#[test]
#[cfg(not(target_os = "windows"))]
fn file_is_html() {
let mut cmd = Command::cargo_bin("artem").unwrap();
cmd.arg("assets/images/standard_test_img.png")
.args(["-o", "/tmp/ascii.html"]);
cmd.assert().success().stdout(predicate::str::starts_with(
"Written 62626 bytes to /tmp/ascii.html",
));
fs::remove_file("/tmp/ascii.html").unwrap();
}
#[test]
#[cfg(not(target_os = "windows"))]
fn file_plain_text() {
let mut cmd = Command::cargo_bin("artem").unwrap();
cmd.arg("assets/images/standard_test_img.png")
.args(["-o", "/tmp/test.txt"]);
cmd.assert().success().stdout(predicate::str::starts_with(
"Written 2105 bytes to /tmp/test.txt",
));
fs::remove_file("/tmp/test.txt").unwrap();
}
}
pub mod verbosity {
use assert_cmd::prelude::*;
use predicates::prelude::*;
use std::process::Command;
#[test]
fn arg_is_none() {
let mut cmd = Command::cargo_bin("artem").unwrap();
cmd.arg("assets/images/standard_test_img.png")
.arg("--verbose");
cmd.assert().failure().stderr(predicate::str::starts_with(
"error: a value is required for '--verbose <verbosity>' but none was supplied",
));
}
#[test]
fn arg_info() {
let mut cmd = Command::cargo_bin("artem").unwrap();
cmd.arg("assets/images/standard_test_img.png")
.args(["--verbose", "info"]);
cmd.assert()
.success()
.stderr(predicate::str::contains("INFO"));
}
#[test]
fn arg_debug() {
let mut cmd = Command::cargo_bin("artem").unwrap();
cmd.arg("assets/images/standard_test_img.png")
.args(["--verbose", "debug"]);
cmd.assert()
.success()
.stderr(predicate::str::contains("DEBUG"));
}
#[test]
fn arg_error() {
let mut cmd = Command::cargo_bin("artem").unwrap();
cmd.arg("examples/abraham_lincoln.nonexisting") .args(["--verbose", "error"]);
cmd.assert()
.failure()
.stderr(predicate::str::contains("ERROR"));
}
}