(8f650fc) Refuse a tab in a tag annotation, and bump to 0.32.5
This commit is contained in:
@@ -316,6 +316,71 @@ fn an_annotation_that_would_read_as_a_heading_is_refused() {
|
||||
assert!(!temp.path().join(".worklane").join("tags.md").exists());
|
||||
}
|
||||
|
||||
/// A tab anywhere in an annotation is refused by `tags add`, because the listing's fields
|
||||
/// are tab separated: past the first tab everything after it reads as a fourth field. The
|
||||
/// refusal says why, and nothing is written — the value parser refuses before the handler
|
||||
/// runs, so not even a placeholder file is left behind.
|
||||
#[test]
|
||||
fn an_annotation_carrying_a_tab_is_refused_by_tags_add() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
setup_worklane(&temp);
|
||||
|
||||
let out = run(&temp, &["tags", "add", "bug", "-a", "Something\twrong."]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
assert!(!out.status.success(), "{stderr}");
|
||||
assert!(
|
||||
stderr.contains("tab") && stderr.contains("separates its fields"),
|
||||
"{stderr}"
|
||||
);
|
||||
assert!(!temp.path().join(".worklane").join("tags.md").exists());
|
||||
|
||||
// No staged write survived either, so the directory holds only the status folders.
|
||||
let left: Vec<_> = fs::read_dir(temp.path().join(".worklane"))
|
||||
.unwrap()
|
||||
.map(|e| e.unwrap().file_name())
|
||||
.collect();
|
||||
assert_eq!(left.len(), 4, "{left:?}");
|
||||
}
|
||||
|
||||
/// The same value is refused by `tags set`, and the declaration that is already there is
|
||||
/// untouched.
|
||||
#[test]
|
||||
fn an_annotation_carrying_a_tab_is_refused_by_tags_set() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
setup_worklane(&temp);
|
||||
|
||||
run(&temp, &["tags", "add", "bug", "-a", "Something wrong."]);
|
||||
let before = vocabulary(&temp);
|
||||
|
||||
let out = run(&temp, &["tags", "set", "bug", "-a", "Now\twith a tab."]);
|
||||
assert!(!out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
|
||||
assert_eq!(vocabulary(&temp), before);
|
||||
}
|
||||
|
||||
/// Ordinary prose is unaffected, paragraphs included: the refusal is for the tab alone,
|
||||
/// which is what keeps it from standing in front of the command's whole purpose.
|
||||
#[test]
|
||||
fn an_annotation_without_a_tab_is_taken_whatever_its_shape() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
setup_worklane(&temp);
|
||||
|
||||
run(
|
||||
&temp,
|
||||
&[
|
||||
"tags",
|
||||
"add",
|
||||
"bug",
|
||||
"-a",
|
||||
"A defect.",
|
||||
"-a",
|
||||
"",
|
||||
"-a",
|
||||
"--plan is prose",
|
||||
],
|
||||
);
|
||||
assert_eq!(declared(&temp, "bug").as_deref(), Some("A defect.\n\n--plan is prose"));
|
||||
}
|
||||
|
||||
/// The file is made on demand, the way `campaign add` makes the campaigns directory: a board
|
||||
/// that predates the vocabulary must not need `worklane init` run over it.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user