taskwarrior/cli/tests/cli.rs
Dustin J. Mitchell 2c579b9f01 Switch to a command-line API closer to TaskWarrior
* Use a parser (rather than clap) to process the command line
* Outline some generic support for filtering, reporting, modifying, etc.
* Break argument parsing strictly from invocation, to allow independent testing
2020-12-19 16:40:09 -05:00

42 lines
999 B
Rust

use assert_cmd::prelude::*;
use predicates::prelude::*;
use std::process::Command;
// NOTE: This tests that the task binary is running and parsing arguments. The details of
// subcommands are handled with unit tests.
#[test]
fn help() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("task")?;
cmd.arg("--help");
cmd.assert()
.success()
.stdout(predicate::str::contains("Personal task-tracking"));
Ok(())
}
#[test]
fn version() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("task")?;
cmd.arg("--version");
cmd.assert()
.success()
.stdout(predicate::str::contains("TaskChampion"));
Ok(())
}
#[test]
fn invalid_option() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("task")?;
cmd.arg("--no-such-option");
cmd.assert()
.failure()
.stderr(predicate::str::contains("command line not recognized"));
Ok(())
}