`cargo clippy --all-targets` was reporting 96 warnings, 14 of them in the binary. It is now clean from a cold cache, and the 211 tests still pass. `clippy --fix` took the mechanical ones: needless borrows, `map_or` that is `is_some_and`, `push_str` of a single character, manual `split_once`, and `&PathBuf` parameters in the test fixtures. It also moved the `handlers.rs` test module to the end of the file, which is what `items_after_test_module` was pointing at. Three by hand. `cmd_add` took nine parameters threaded from `main`, and now takes `AddArgs`, which is how `set`, `append` and `check` already pass theirs; the handler destructures it so the body reads as before, and `add --help` is unchanged. The collapsed `if` in `content_trim` needed reindenting, since `--fix` left its body at the old depth. And the two `split_once` rewrites read as `.split_once(..).map(|(_, value)| value)` rather than clippy's `.map(|x| x.1)`. The two eight-argument `create_ticket` test fixtures keep an `allow(too_many_arguments)` carrying the reason: the lint is right that twenty-five positional call sites read as a wall of strings, but replacing them with a named-field struct is a refactor and not a warning sweep. a34a316 tracks it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
83 lines
2.7 KiB
Rust
83 lines
2.7 KiB
Rust
use assert_cmd::Command;
|
|
use assert_fs::TempDir;
|
|
use assert_fs::fixture::{PathChild, PathCreateDir};
|
|
|
|
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
|
|
|
fn setup_worklane(temp: &TempDir) {
|
|
let worklane = temp.child(".worklane");
|
|
worklane.create_dir_all().unwrap();
|
|
|
|
for dir in ["backlog", "committed", "reviewing", "done"] {
|
|
worklane.child(dir).create_dir_all().unwrap();
|
|
}
|
|
}
|
|
|
|
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
|
|
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
|
cmd.current_dir(temp.path()).args(args);
|
|
cmd.assert().get_output().clone()
|
|
}
|
|
|
|
/// Same message every other command gives. Checked before the terminal is, so the
|
|
/// missing board is what gets reported rather than the missing tty.
|
|
#[test]
|
|
fn the_tui_outside_a_worklane_directory_gives_the_usual_message() {
|
|
let temp = TempDir::new().unwrap();
|
|
|
|
for args in [vec!["tui"], vec![]] {
|
|
let out = run(&temp, &args);
|
|
let stderr = String::from_utf8_lossy(&out.stderr);
|
|
|
|
assert_eq!(out.status.code(), Some(1), "{args:?}");
|
|
assert!(
|
|
stderr.contains("No .worklane directory found"),
|
|
"{args:?}: {stderr:?}"
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Raw mode on a pipe fails with a bare "No such device or address", which says nothing
|
|
/// about the mistake. A bare `worklane` is how the board opens, so a script that lands
|
|
/// here by accident has to be pointed at a subcommand.
|
|
#[test]
|
|
fn the_tui_without_a_terminal_says_so_and_names_an_alternative() {
|
|
let temp = TempDir::new().unwrap();
|
|
setup_worklane(&temp);
|
|
|
|
for args in [vec!["tui"], vec![]] {
|
|
let out = run(&temp, &args);
|
|
let stderr = String::from_utf8_lossy(&out.stderr);
|
|
|
|
assert_eq!(out.status.code(), Some(1), "{args:?}");
|
|
assert!(stderr.contains("needs a terminal"), "{args:?}: {stderr:?}");
|
|
assert!(stderr.contains("worklane ls"), "{args:?}: {stderr:?}");
|
|
assert!(
|
|
!stderr.contains("os error"),
|
|
"the raw mode error leaked: {stderr:?}"
|
|
);
|
|
}
|
|
}
|
|
|
|
/// The subcommands must keep working now that the subcommand is optional.
|
|
#[test]
|
|
fn an_unknown_subcommand_is_still_a_usage_error() {
|
|
let temp = TempDir::new().unwrap();
|
|
setup_worklane(&temp);
|
|
|
|
assert_eq!(run(&temp, &["nonsense"]).status.code(), Some(2));
|
|
assert_eq!(run(&temp, &["--bogus"]).status.code(), Some(2));
|
|
}
|
|
|
|
/// `tui` has to appear in the help, or nothing points at it.
|
|
#[test]
|
|
fn the_help_lists_the_tui_command() {
|
|
let temp = TempDir::new().unwrap();
|
|
|
|
let out = run(&temp, &["--help"]);
|
|
let stdout = String::from_utf8_lossy(&out.stdout);
|
|
|
|
assert!(out.status.success());
|
|
assert!(stdout.contains("tui"), "{stdout:?}");
|
|
}
|