use super::*;
use crate::cli_outbound::self_exe::{self_exe, usable};
use tempfile::tempdir;
#[test]
fn a_reading_is_usable_only_when_the_file_is_actually_there() {
let dir = tempdir().unwrap();
let real = dir.path().join("yog");
fs::write(&real, "#!/bin/sh\nexit 0\n").unwrap();
assert_eq!(usable(Some(real.clone())), Some(real.clone()));
let annotated = dir.path().join("yog (deleted)");
assert_eq!(usable(Some(annotated.clone())), None);
fs::write(&annotated, "#!/bin/sh\nexit 0\n").unwrap();
assert_eq!(usable(Some(annotated.clone())), Some(annotated));
assert_eq!(usable(Some(dir.path().join("gone"))), None);
assert_eq!(usable(None), None);
assert_eq!(usable(Some(dir.path().to_path_buf())), None);
}
#[test]
fn the_process_reads_its_own_executable_once() {
let first = self_exe();
assert_eq!(first, self_exe());
let exe = first.expect("this test binary is on disk");
assert!(exe.is_file(), "{exe:?}");
}