mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 22:25:26 +00:00
Fix issue w/ existing files not being updated in imfs (#119)
* Fix issue w/ existing files not being updated in imfs * Add a test for updating files
This commit is contained in:
committed by
Lucien Greathouse
parent
b58fed16b4
commit
0ff59ecb4e
@@ -208,7 +208,6 @@ impl Imfs {
|
|||||||
if self.items.contains_key(&next_path) {
|
if self.items.contains_key(&next_path) {
|
||||||
current_path = next_path;
|
current_path = next_path;
|
||||||
} else {
|
} else {
|
||||||
self.read_from_disk(¤t_path)?;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -216,7 +215,7 @@ impl Imfs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
self.read_from_disk(¤t_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_from_disk(&mut self, path: &Path) -> Result<(), FsError> {
|
fn read_from_disk(&mut self, path: &Path) -> Result<(), FsError> {
|
||||||
|
|||||||
@@ -254,6 +254,35 @@ fn adding_folder() -> Result<(), Error> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn updating_files() -> Result<(), Error> {
|
||||||
|
let (_root, mut imfs, mut expected_imfs, resources) = base_tree()?;
|
||||||
|
|
||||||
|
check_expected(&imfs, &expected_imfs);
|
||||||
|
|
||||||
|
fs::write(&resources.bar_path, b"bar updated")?;
|
||||||
|
fs::write(&resources.baz_path, b"baz updated")?;
|
||||||
|
|
||||||
|
imfs.path_updated(&resources.bar_path)?;
|
||||||
|
imfs.path_updated(&resources.baz_path)?;
|
||||||
|
|
||||||
|
let bar_updated_item = ImfsItem::File(ImfsFile {
|
||||||
|
path: resources.bar_path.clone(),
|
||||||
|
contents: b"bar updated".to_vec(),
|
||||||
|
});
|
||||||
|
let baz_updated_item = ImfsItem::File(ImfsFile {
|
||||||
|
path: resources.baz_path.clone(),
|
||||||
|
contents: b"baz updated".to_vec(),
|
||||||
|
});
|
||||||
|
|
||||||
|
expected_imfs.items.insert(resources.bar_path.clone(), bar_updated_item);
|
||||||
|
expected_imfs.items.insert(resources.baz_path.clone(), baz_updated_item);
|
||||||
|
|
||||||
|
check_expected(&imfs, &expected_imfs);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn removing_file() -> Result<(), Error> {
|
fn removing_file() -> Result<(), Error> {
|
||||||
let (root, mut imfs, mut expected_imfs, resources) = base_tree()?;
|
let (root, mut imfs, mut expected_imfs, resources) = base_tree()?;
|
||||||
|
|||||||
Reference in New Issue
Block a user