memory tests: mkdir -p before seeding fixture files
init() scaffolds only system/; the other schema roots are created on first write by the real write path. Three tests seeded fixtures directly into issues/, projects/ and reference/ and died on ENOENT, which failed cargo test and skipped the packaging job that publishes the pacman repo.
This commit is contained in:
parent
336dadf006
commit
687cfeb5fb
1 changed files with 24 additions and 28 deletions
|
|
@ -1502,6 +1502,18 @@ mod tests {
|
|||
assert!(MemoryRepo::is_frontmatter_bound("projects/journal-of-x.md"));
|
||||
}
|
||||
|
||||
/// Seed a file at `rel` under the repo root, creating parent directories.
|
||||
/// `init()` scaffolds only `system/`; the other schema roots (issues/,
|
||||
/// projects/, reference/, tasks/, journal/) are created on first write by
|
||||
/// the real write path, so tests seeding fixtures directly must mkdir -p.
|
||||
fn seed_file(repo: &MemoryRepo, rel: &str, contents: &str) {
|
||||
let path = repo.root().join(rel);
|
||||
if let Some(parent) = path.parent() {
|
||||
std::fs::create_dir_all(parent).unwrap();
|
||||
}
|
||||
std::fs::write(path, contents).unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_write_rejects_empty_description_on_bound_file() {
|
||||
let dir = TempDir::new().unwrap();
|
||||
|
|
@ -1509,11 +1521,11 @@ mod tests {
|
|||
repo.init().await.unwrap();
|
||||
|
||||
// Seed a frontmatter-bound file with NO description (the gap).
|
||||
std::fs::write(
|
||||
repo.root().join("issues/gap.md"),
|
||||
seed_file(
|
||||
&repo,
|
||||
"issues/gap.md",
|
||||
"---\nread_only: false\n---\nBody with no description\n",
|
||||
)
|
||||
.unwrap();
|
||||
);
|
||||
|
||||
// A body-only write must not silently perpetuate the empty description.
|
||||
let err = repo.write("issues/gap.md", "updated body").await.unwrap_err();
|
||||
|
|
@ -1557,11 +1569,7 @@ mod tests {
|
|||
repo.init().await.unwrap();
|
||||
|
||||
// Existing bound file missing description.
|
||||
std::fs::write(
|
||||
repo.root().join("projects/gap.md"),
|
||||
"---\n---\nInitial body\n",
|
||||
)
|
||||
.unwrap();
|
||||
seed_file(&repo, "projects/gap.md", "---\n---\nInitial body\n");
|
||||
|
||||
let err = repo.append("projects/gap.md", "more").await.unwrap_err();
|
||||
assert!(err.to_string().contains("no description"));
|
||||
|
|
@ -1574,28 +1582,16 @@ mod tests {
|
|||
repo.init().await.unwrap();
|
||||
|
||||
// Bound + missing description → flagged.
|
||||
std::fs::write(
|
||||
repo.root().join("issues/missing.md"),
|
||||
"---\n---\nbody\n",
|
||||
)
|
||||
.unwrap();
|
||||
seed_file(&repo, "issues/missing.md", "---\n---\nbody\n");
|
||||
// Bound + has description → not flagged.
|
||||
std::fs::write(
|
||||
repo.root().join("reference/has.md"),
|
||||
seed_file(
|
||||
&repo,
|
||||
"reference/has.md",
|
||||
"---\ndescription: present\n---\nbody\n",
|
||||
)
|
||||
.unwrap();
|
||||
);
|
||||
// Unbound schema + no description → not flagged (legitimate).
|
||||
std::fs::write(
|
||||
repo.root().join("tasks/todo.md"),
|
||||
"---\nid: t1\n---\nbody\n",
|
||||
)
|
||||
.unwrap();
|
||||
std::fs::write(
|
||||
repo.root().join("journal/2026/05/20.md"),
|
||||
"---\n---\nfreeform\n",
|
||||
)
|
||||
.unwrap();
|
||||
seed_file(&repo, "tasks/todo.md", "---\nid: t1\n---\nbody\n");
|
||||
seed_file(&repo, "journal/2026/05/20.md", "---\n---\nfreeform\n");
|
||||
|
||||
let missing = repo.audit().await.unwrap();
|
||||
assert_eq!(missing, vec!["issues/missing.md".to_string()]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue