use assert_cmd::prelude::*;
use std::process::Command;
use tempfile::TempDir;
fn pend_bin() -> Command {
Command::cargo_bin("pend").expect("binary")
}
fn pend_with_temp() -> (TempDir, Command) {
let tmp = TempDir::new().expect("tmpdir");
let mut cmd = pend_bin();
cmd.env("PEND_DIR", tmp.path());
(tmp, cmd)
}
#[test]
fn lock_removed_after_job_finishes() {
let (tmp, mut pend) = pend_with_temp();
pend.args(["do", "cleanlock", "bash", "-c", "echo hi"])
.assert()
.success();
pend_bin()
.env("PEND_DIR", tmp.path())
.args(["wait", "cleanlock"])
.assert()
.success();
let lock_path = tmp.path().join("cleanlock.lock");
assert!(!lock_path.exists(), "lock file still present after completion");
}