ooo tests pass
parent
5bfd9e52c3
commit
bef9ef1a2a
|
|
@ -39,12 +39,6 @@ fn main() {
|
||||||
|
|
||||||
if flags.edit {
|
if flags.edit {
|
||||||
edit::files(&files);
|
edit::files(&files);
|
||||||
for file in files.files.iter() {
|
|
||||||
file.persist_stage()
|
|
||||||
.expect("failed to persist edited stage to log file");
|
|
||||||
file.stage_persisted()
|
|
||||||
.expect("failed to stage edits from log files");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -576,7 +570,12 @@ mod tests {
|
||||||
pub fn file_contains(d: &tempdir::TempDir, fname: &str, content: &str) {
|
pub fn file_contains(d: &tempdir::TempDir, fname: &str, content: &str) {
|
||||||
let p = d.path().join(&fname);
|
let p = d.path().join(&fname);
|
||||||
let file_content = file_content(&p.to_str().unwrap().to_string());
|
let file_content = file_content(&p.to_str().unwrap().to_string());
|
||||||
assert!(file_content.contains(content));
|
assert!(
|
||||||
|
file_content.contains(content),
|
||||||
|
"expected {:?} but got {:?}",
|
||||||
|
content,
|
||||||
|
file_content
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn file_content(p: &String) -> String {
|
pub fn file_content(p: &String) -> String {
|
||||||
|
|
@ -616,6 +615,7 @@ mod edit {
|
||||||
let before = file.stage()?;
|
let before = file.stage()?;
|
||||||
let after = new_files.files[i].stage()?;
|
let after = new_files.files[i].stage()?;
|
||||||
file.persist_delta(before, after)?;
|
file.persist_delta(before, after)?;
|
||||||
|
file.stage_persisted()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -650,16 +650,25 @@ mod edit {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_persist_edits_with_files() {
|
fn test_persist_edits_with_files() {
|
||||||
|
let hostname = gethostname::gethostname().into_string().unwrap();
|
||||||
|
let log_file = format!(".file.{}", hostname);
|
||||||
|
let log_file = log_file.as_str();
|
||||||
tests::with_dir(|d1| {
|
tests::with_dir(|d1| {
|
||||||
tests::write_file(&d1, "file", "- foo");
|
tests::write_file(&d1, "file", "- foo");
|
||||||
let p = d1.path().join("file").display().to_string();
|
let p = d1.path().join("file").display().to_string();
|
||||||
let files = Files::new(&vec![p]);
|
let files = Files::new(&vec![p]);
|
||||||
|
files.files[0].persist_stage().expect("failed to init log");
|
||||||
|
tests::file_contains(&d1, log_file, r#""foo""#);
|
||||||
tests::with_dir(|d2| {
|
tests::with_dir(|d2| {
|
||||||
build_dir(&d2, &files).expect("failed to build dir");
|
build_dir(&d2, &files).expect("failed to build dir");
|
||||||
tests::file_contains(&d2, "file", "- foo");
|
tests::file_contains(&d2, "file", "- foo");
|
||||||
tests::write_file(&d2, "file", "- foobar\n- bar");
|
tests::write_file(&d2, "file", "- foobar\n- bar");
|
||||||
|
|
||||||
persist_edits(&d2, &files).expect("failed to persist edits");
|
persist_edits(&d2, &files).expect("failed to persist edits");
|
||||||
|
tests::file_contains(&d1, "file", "- foobar\n- bar");
|
||||||
|
tests::file_contains(&d1, log_file, r#""foo""#);
|
||||||
|
tests::file_contains(&d1, log_file, r#""foobar""#);
|
||||||
|
tests::file_contains(&d1, log_file, r#""bar""#);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue