(1f1b321) Record a move's reason in its history entry, and bump to 0.31.2
This commit is contained in:
@@ -114,6 +114,94 @@ fn mv_writes_a_status_entry() {
|
||||
assert!(entry.contains("**Author**: claude"), "{entry:?}");
|
||||
}
|
||||
|
||||
/// One file, one event, its explanation: `--reason` rides in the status entry that
|
||||
/// records the transition it explains, as a field after **Time**, and `show` renders it
|
||||
/// indented under the row rather than as a paragraph of its own.
|
||||
#[test]
|
||||
fn the_reason_travels_with_its_transition() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane, "reviewing");
|
||||
|
||||
run(
|
||||
&temp,
|
||||
&[
|
||||
"mv",
|
||||
UUID,
|
||||
"--status",
|
||||
"backlog",
|
||||
"-f",
|
||||
"--reason",
|
||||
"sent back: the first plan was wrong",
|
||||
],
|
||||
);
|
||||
|
||||
let entry = only_entry(&worklane, "status");
|
||||
assert!(entry.starts_with("**Status**\nreviewing → backlog\n"), "{entry:?}");
|
||||
assert!(
|
||||
entry.ends_with("**Reason**: sent back: the first plan was wrong\n"),
|
||||
"{entry:?}"
|
||||
);
|
||||
|
||||
let out = run(&temp, &["show", UUID]);
|
||||
let stdout = String::from_utf8(out.stdout).unwrap();
|
||||
|
||||
let moved = stdout.find("reviewing → backlog").expect("the move is missing");
|
||||
let reason = stdout
|
||||
.find("\n sent back: the first plan was wrong")
|
||||
.expect("the reason is missing");
|
||||
// Attached means the very next line: nothing, not even a blank line, between.
|
||||
assert!(
|
||||
!stdout[moved..reason].contains('\n'),
|
||||
"the reason is detached from its row:\n{stdout}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The unusual moves are exactly the ones that need a why, so a refused one must not
|
||||
/// log one either: the entry is written after the edit, and there was no edit.
|
||||
#[test]
|
||||
fn a_refused_move_writes_no_reason_either() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane, "reviewing");
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"mv",
|
||||
UUID,
|
||||
"--status",
|
||||
"backlog",
|
||||
"--reason",
|
||||
"this move never happened",
|
||||
],
|
||||
);
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert_eq!(entries(&worklane), vec![], "a refused move logged its reason");
|
||||
}
|
||||
|
||||
/// Same for the move that changes nothing.
|
||||
#[test]
|
||||
fn a_no_op_move_writes_no_reason_either() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane, "committed");
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"mv",
|
||||
UUID,
|
||||
"--status",
|
||||
"committed",
|
||||
"--reason",
|
||||
"nothing moved",
|
||||
],
|
||||
);
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
assert_eq!(entries(&worklane), vec![], "a no-op move logged its reason");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chown_writes_an_owner_entry() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user