The flow ended at done, so a ticket that turned out to be a duplicate or obsolete had nowhere to go: it sat in the backlog or was deleted by hand, which destroyed the record and left every relation to it dangling. Discarded is a fifth status with its own directory, keeping the invariant that the filename, the Status field and the directory agree, and keeping done meaning the work landed. Entering it is allowed from any status without -f, because discarding is not a stage of work. Discarded sits last in Status::ALL, which is what makes the rest fall out rather than needing cases: nothing follows it, so a discard clears no stamp and a ticket abandoned from reviewing keeps the journey it made, and every move out is a backward move, so un-discarding needs -f. The two dependency guards now look opposite ways. check_blockers asks what a ticket waits on and gates work moves; check_dependents asks who waits on it and gates the discard, because those plans depended on work about to be declared never-happening. Both skip targets that are themselves terminal. Status::FLOW is the four stages the board draws, so a discarded column on screen stays a136d13's ticket and done stays the last drawn column. Every tree walker keeps using Status::ALL, or a discarded ticket would be unaddressable. util::is_open replaces three spellings of "not done and not discarded", across mv, ls and the campaign standing. The board's blocked mark goes through it as well: that path was only accidentally correct, since a discarded blocker is absent from the FLOW columns, and drawing the column later would have diverged it from what mv allows. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
78 lines
2.9 KiB
Rust
78 lines
2.9 KiB
Rust
use assert_cmd::Command;
|
|
|
|
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
|
|
|
fn script(shell: &str) -> String {
|
|
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
|
let assert = cmd.arg("completions").arg(shell).assert().success();
|
|
String::from_utf8(assert.get_output().stdout.clone()).unwrap()
|
|
}
|
|
|
|
/// Every shell clap can generate for, since the README names all five.
|
|
#[test]
|
|
fn completions_prints_a_script_for_every_shell() {
|
|
for shell in ["fish", "bash", "zsh", "elvish", "powershell"] {
|
|
let out = script(shell);
|
|
assert!(out.contains("worklane"), "the {shell} script never names the command");
|
|
// Long enough to be a script rather than an empty file with a comment in it.
|
|
assert!(out.len() > 500, "the {shell} script is {} bytes", out.len());
|
|
}
|
|
}
|
|
|
|
/// No board is looked for, the way `install-skill` looks for none: the script comes off
|
|
/// the clap definition and is the same wherever it is run. Run from a temp directory
|
|
/// with no `.worklane` above it, which every other command refuses.
|
|
#[test]
|
|
fn completions_needs_no_board() {
|
|
let temp = assert_fs::TempDir::new().unwrap();
|
|
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
|
cmd.current_dir(temp.path())
|
|
.arg("completions")
|
|
.arg("fish")
|
|
.assert()
|
|
.success();
|
|
}
|
|
|
|
#[test]
|
|
fn fish_gets_both_halves() {
|
|
let out = script("fish");
|
|
// clap's, which is where the subcommands and the flags come from.
|
|
assert!(out.contains("__fish_worklane_needs_command"));
|
|
assert!(out.contains("install-skill"));
|
|
// Ours, which is where the tickets come from.
|
|
assert!(out.contains("__worklane_first_arg_of"));
|
|
assert!(out.contains("worklane ls --ids"));
|
|
}
|
|
|
|
/// The fish half is fish syntax, so it must not reach any other shell's output.
|
|
#[test]
|
|
fn no_other_shell_gets_the_fish_half() {
|
|
for shell in ["bash", "zsh", "elvish", "powershell"] {
|
|
let out = script(shell);
|
|
assert!(
|
|
!out.contains("__worklane_first_arg_of"),
|
|
"fish-only helpers leaked into {shell}"
|
|
);
|
|
assert!(!out.contains("worklane ls --ids"), "the dynamic half leaked into {shell}");
|
|
}
|
|
}
|
|
|
|
/// The four statuses reach fish twice over, from clap for the `mv` option and from the
|
|
/// appended half for the `ls` positional, which clap emits nothing for.
|
|
#[test]
|
|
fn fish_is_offered_every_status() {
|
|
let out = script("fish");
|
|
for status in ["backlog", "committed", "reviewing", "done", "discarded"] {
|
|
assert!(out.contains(status), "fish is never offered {status}");
|
|
}
|
|
assert!(out.contains("-a 'backlog committed reviewing done discarded' -d status"));
|
|
}
|
|
|
|
#[test]
|
|
fn an_unknown_shell_is_a_usage_error() {
|
|
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
|
let assert = cmd.arg("completions").arg("tcsh").assert().code(2);
|
|
let stderr = String::from_utf8(assert.get_output().stderr.clone()).unwrap();
|
|
assert!(stderr.contains("invalid value 'tcsh'"), "{stderr}");
|
|
}
|