Refactor: Formalize ports and update related files
This commit is contained in:
@@ -19,7 +19,7 @@ fn test_hook_success() {
|
||||
let dir = TempDir::new().unwrap();
|
||||
let spec = make_hook_script(&dir, "ok-hook", "echo hello");
|
||||
let runner = HookRunner::new(dir.path().to_path_buf());
|
||||
let result = runner.run_hook(&spec);
|
||||
let result = runner.run_hook(&spec).unwrap();
|
||||
assert!(matches!(result, HookResult::Ok));
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ fn test_hook_failure() {
|
||||
let dir = TempDir::new().unwrap();
|
||||
let spec = make_hook_script(&dir, "fail-hook", "exit 1");
|
||||
let runner = HookRunner::new(dir.path().to_path_buf());
|
||||
let result = runner.run_hook(&spec);
|
||||
let result = runner.run_hook(&spec).unwrap();
|
||||
assert!(matches!(result, HookResult::Failed(_)));
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ fn test_setup_hook_skipped_on_rerun() {
|
||||
spec.phase = notcore::HookPhase::Setup;
|
||||
|
||||
let runner = HookRunner::new(dir.path().to_path_buf());
|
||||
let r1 = runner.run_hook(&spec);
|
||||
let r1 = runner.run_hook(&spec).unwrap();
|
||||
assert!(matches!(r1, HookResult::Ok));
|
||||
|
||||
// Second run — should be skipped
|
||||
let r2 = runner.run_hook(&spec);
|
||||
let r2 = runner.run_hook(&spec).unwrap();
|
||||
assert!(matches!(r2, HookResult::Skipped));
|
||||
}
|
||||
|
||||
@@ -54,9 +54,29 @@ fn test_setup_hook_force_reruns() {
|
||||
spec.phase = notcore::HookPhase::Setup;
|
||||
|
||||
let runner = HookRunner::new(dir.path().to_path_buf());
|
||||
runner.run_hook(&spec);
|
||||
runner.run_hook(&spec).unwrap();
|
||||
|
||||
let runner2 = HookRunner::with_force(dir.path().to_path_buf());
|
||||
let r2 = runner2.run_hook(&spec);
|
||||
let r2 = runner2.run_hook(&spec).unwrap();
|
||||
assert!(matches!(r2, HookResult::Ok));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_relative_script_path_resolves_from_state_dir() {
|
||||
let dir = TempDir::new().unwrap();
|
||||
let scripts_dir = dir.path().join("scripts");
|
||||
fs::create_dir_all(&scripts_dir).unwrap();
|
||||
let script = scripts_dir.join("relative.sh");
|
||||
fs::write(&script, "echo relative-ok").unwrap();
|
||||
|
||||
let spec = HookSpec {
|
||||
name: "relative".to_string(),
|
||||
script: "scripts/relative.sh".to_string(),
|
||||
phase: HookPhase::Dot,
|
||||
interpreter: Some("sh".to_string()),
|
||||
};
|
||||
|
||||
let runner = HookRunner::new(dir.path().to_path_buf());
|
||||
let result = runner.run_hook(&spec).unwrap();
|
||||
assert!(matches!(result, HookResult::Ok));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user