use super::*;
fn ctx() -> HookContext {
HookContext {
owner: "acme".into(),
repo: "api".into(),
issue: "42".into(),
branch: "issue-42".into(),
worktree_path: "/tmp/wt".into(),
}
}
#[cfg(not(windows))]
#[test]
fn test_run_hook_multiline_executes_all_lines() {
let out = std::env::temp_dir().join("worktree-test-multiline-hook.txt");
let _ = std::fs::remove_file(&out);
let path = out.to_str().unwrap().to_string();
let script = format!("printf 'first' > '{path}'\nprintf 'second' >> '{path}'\n");
run_hook(&script, &ctx()).unwrap();
let content = std::fs::read_to_string(&out).unwrap_or_default();
let _ = std::fs::remove_file(&out);
assert_eq!(
content, "firstsecond",
"all lines of a multi-line hook must run"
);
}