mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-22 21:55:15 +00:00
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:
committed by
GitHub
parent
a70b7ee150
commit
e741f7b557
37
src/snapshot/tests/apply.rs
Normal file
37
src/snapshot/tests/apply.rs
Normal 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(),
|
||||
})
|
||||
}
|
||||
35
src/snapshot/tests/compute.rs
Normal file
35
src/snapshot/tests/compute.rs
Normal 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(),
|
||||
})
|
||||
}
|
||||
2
src/snapshot/tests/mod.rs
Normal file
2
src/snapshot/tests/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
mod apply;
|
||||
mod compute;
|
||||
Reference in New Issue
Block a user