feat(import): a folder of one CSV keeps its File category and view (improvise-lpzu)

The user's ruling on PR #314: a folder always merges, so even a single
CSV in it records its file identity. A CSV named directly still imports
alone. The "(none)" question is answered as no position, per the user.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VdfEGXA7aJ6ftMsCc9PJze
This commit is contained in:
Claude (agent-lpzu)
2026-09-24 21:36:00 -07:00
committed by Edward Langley
parent 4e68372c25
commit 005b7a769a
6 changed files with 79 additions and 11 deletions
+31
View File
@@ -708,3 +708,34 @@ fn a_headless_import_takes_files_and_folders_together_and_refuses_an_empty_folde
);
assert!(!scratch.path("never.improv").exists());
}
/// improvise-lpzu, the user's ruling: a folder always merges, so even one CSV
/// keeps its file identity. Evidence: `context/test-evidence/cli.md`.
#[test]
fn a_folder_of_one_csv_still_gets_a_file_category_and_its_view_but_a_lone_file_does_not() {
let scratch = Scratch::new("folder_single");
let dir = scratch.path("one");
std::fs::create_dir_all(&dir).unwrap();
let csv = dir.join("age.csv");
std::fs::write(&csv, "entity,age-months\nsrc/a.rs,2\n").unwrap();
let from_folder = scratch.path("folder.improv");
let out = run_import(&dir, &from_folder, &[]);
assert!(out.status.success(), "{}", stderr_of(&out));
let doc = std::fs::read_to_string(&from_folder).unwrap();
assert!(doc.contains("## Category: File\n- age\n"), "{doc}");
assert!(doc.lines().any(|l| l == "File: filter, age"), "{doc}");
assert!(
doc.contains("File=age, _Measure=age-months, entity=|src/a.rs| = 2"),
"{doc}"
);
let from_file = scratch.path("file.improv");
let out = run_import(&csv, &from_file, &[]);
assert!(out.status.success(), "{}", stderr_of(&out));
let doc = std::fs::read_to_string(&from_file).unwrap();
assert!(
!doc.contains("File"),
"a lone file keeps today's shape: {doc}"
);
}