[feat] enhance integration test to verify nested output directory creation and update TODO items

This commit is contained in:
2025-08-08 12:24:48 +02:00
parent b1cef02a55
commit 66954150b2
2 changed files with 21 additions and 13 deletions

View File

@@ -3,8 +3,8 @@
- [x] rename project to "PolyScribe"
- [x] add tests
- [x] update local models using hashes (--update-models)
- create folder models/ if not present -> use /usr/share/polyscribe/models/ for release version, use ./models/ for development version
- create missing folders for output files
- [x] create folder models/ if not present -> use /usr/share/polyscribe/models/ for release version, use ./models/ for development version
- [x] create missing folders for output files
- for merging (command line flag) -> if not present, treat each file as separate output (--merge | -m)
- for merge + separate output -> if present, treat each file as separate output and also output a merged version (--merge-and-separate)
- set speaker-names per input-file -> prompt user for each file if flag is set (--set-speaker-names)

View File

@@ -48,7 +48,9 @@ fn manifest_path(relative: &str) -> PathBuf {
fn cli_merges_json_inputs_and_writes_outputs_to_temp_dir() {
let exe = env!("CARGO_BIN_EXE_polyscribe");
let tmp = TestDir::new();
let base = tmp.path().join("out");
// Use a nested output directory to also verify auto-creation
let base_dir = tmp.path().join("outdir");
let base = base_dir.join("out");
let input1 = manifest_path("input/1-s0wlz.json");
let input2 = manifest_path("input/2-vikingowl.json");
@@ -63,16 +65,22 @@ fn cli_merges_json_inputs_and_writes_outputs_to_temp_dir() {
.expect("failed to spawn polyscribe");
assert!(status.success(), "CLI did not exit successfully");
// Expect files with today's date prefix
let date = Local::now().format("%Y-%m-%d").to_string();
let stem = format!("{}_{}", date, "out");
let json_path = tmp.path().join(format!("{}.json", stem));
let toml_path = tmp.path().join(format!("{}.toml", stem));
let srt_path = tmp.path().join(format!("{}.srt", stem));
assert!(json_path.is_file(), "missing JSON output: {}", json_path.display());
assert!(toml_path.is_file(), "missing TOML output: {}", toml_path.display());
assert!(srt_path.is_file(), "missing SRT output: {}", srt_path.display());
// Find the created files in the chosen output directory without depending on date prefix
let entries = fs::read_dir(&base_dir).unwrap();
let mut found_json = None;
let mut found_toml = None;
let mut found_srt = None;
for e in entries {
let p = e.unwrap().path();
if let Some(name) = p.file_name().and_then(|s| s.to_str()) {
if name.ends_with("_out.json") { found_json = Some(p.clone()); }
if name.ends_with("_out.toml") { found_toml = Some(p.clone()); }
if name.ends_with("_out.srt") { found_srt = Some(p.clone()); }
}
}
let json_path = found_json.expect("missing JSON output in temp dir");
let toml_path = found_toml.expect("missing TOML output in temp dir");
let srt_path = found_srt.expect("missing SRT output in temp dir");
// Parse JSON and perform sanity checks
let mut json_str = String::new();