Ok(())
}
/// Test that `record` notices the deletion of a file.
#[test]
fn del_obsolete_test() -> Result<(), anyhow::Error> {
env_logger::try_init().unwrap_or(());
let mut repo = working_copy::memory::Memory::new();
let changes = changestore::memory::Memory::new();
let env = pristine::sanakirja::Pristine::new_anon()?;
let mut txn = env.mut_txn_begin();
txn.add_file("a/b/c/d/e")?;
let mut channel = txn.open_or_create_channel("main")?;
repo.add_file("a/b/c/d/e", b"a\nb\nc\nd\ne\nf\n".to_vec());
record_all_output(&mut repo, &changes, &mut txn, &mut channel, "")?;
debug_to_file(&txn, &channel, "debug0").unwrap();
let files: Vec<_> = crate::fs::iter_working_copy(&txn, Inode::ROOT)
.map(|(_, file)| file)
.collect();
assert_eq!(files, vec!["a", "a/b", "a/b/c", "a/b/c/d", "a/b/c/d/e"]);
repo.remove_path("a/b/c")?;
debug!("Recording the deletion");
record_all_output(&mut repo, &changes, &mut txn, &mut channel, "")?;
debug_to_file(&txn, &channel, "debug").unwrap();
let mut repo2 = working_copy::memory::Memory::new();
output::output_repository_no_pending(&mut repo2, &changes, &mut txn, &mut channel, "", true)?;
assert_eq!(repo2.list_files(), vec!["a", "a/b"]);
let files: Vec<_> = crate::fs::iter_working_copy(&txn, Inode::ROOT)
.map(|(_, name)| name)
.collect();
debug!("files = {:?}", files);
assert_eq!(files, vec!["a", "a/b"]);