Actually generate AppliedPatchSet objects (#250)

* Start actually computing AppliedPatchSet values

* Improve patch_apply documentation and flesh out applied patch code

* Add file link notes

* Stub out where tests for snapshot subsystem will go

* Create baseline tests

* Fix build failure by silencing Clippy
This commit is contained in:
Lucien Greathouse
2019-09-27 15:07:11 -07:00
committed by GitHub
parent a70b7ee150
commit e741f7b557
7 changed files with 190 additions and 33 deletions

View File

@@ -0,0 +1,37 @@
use rbx_dom_weak::RbxInstanceProperties;
use crate::snapshot::{
apply_patch_set, InstancePropertiesWithMeta, PatchSet, PatchUpdate, RojoTree,
};
#[test]
fn reify_folder() {
let mut tree = empty_tree();
let patch_set = PatchSet {
updated_instances: vec![PatchUpdate {
id: tree.get_root_id(),
changed_name: Some("Hello, world!".to_owned()),
changed_class_name: Some("Folder".to_owned()),
changed_properties: Default::default(),
changed_metadata: None,
}],
..Default::default()
};
let _applied_patch_set = apply_patch_set(&mut tree, patch_set);
// TODO: Make assertions about tree using snapshots
// TODO: make assertions about applied patch set using snapshots
}
fn empty_tree() -> RojoTree {
RojoTree::new(InstancePropertiesWithMeta {
properties: RbxInstanceProperties {
name: "ROOT".to_owned(),
class_name: "ROOT".to_owned(),
properties: Default::default(),
},
metadata: Default::default(),
})
}

View File

@@ -0,0 +1,35 @@
use std::borrow::Cow;
use rbx_dom_weak::RbxInstanceProperties;
use crate::snapshot::{compute_patch_set, InstancePropertiesWithMeta, InstanceSnapshot, RojoTree};
#[test]
fn reify_folder() {
let tree = empty_tree();
let folder = InstanceSnapshot {
snapshot_id: None,
metadata: Default::default(),
name: Cow::Borrowed("Some Folder"),
class_name: Cow::Borrowed("Folder"),
properties: Default::default(),
children: Vec::new(),
};
let _patch_set = compute_patch_set(&folder, &tree, tree.get_root_id());
// TODO: Make assertions about patch set using snapshots. This needs patches
// to be serializable and also to have ID redactions more readily available.
}
fn empty_tree() -> RojoTree {
RojoTree::new(InstancePropertiesWithMeta {
properties: RbxInstanceProperties {
name: "ROOT".to_owned(),
class_name: "ROOT".to_owned(),
properties: Default::default(),
},
metadata: Default::default(),
})
}

View File

@@ -0,0 +1,2 @@
mod apply;
mod compute;