Test for AppliedPatchSet result

This commit is contained in:
Lucien Greathouse
2019-09-30 17:13:56 -07:00
parent 5f5bfadf2b
commit 0a1fa9588f
3 changed files with 26 additions and 6 deletions

View File

@@ -61,7 +61,7 @@ pub struct PatchUpdate {
///
// TODO: Introduce machinery to detect conflicts, like keeping previous +
// current values in all fields.
#[derive(Debug, Clone, Default)]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct AppliedPatchSet {
pub removed: Vec<RbxId>,
pub added: Vec<RbxId>,
@@ -78,7 +78,7 @@ impl AppliedPatchSet {
}
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AppliedPatchUpdate {
pub id: RbxId,

View File

@@ -1,12 +1,18 @@
use insta::assert_yaml_snapshot;
use rbx_dom_weak::RbxInstanceProperties;
use rojo_insta_ext::RedactionMap;
use crate::snapshot::{
apply_patch_set, InstancePropertiesWithMeta, PatchSet, PatchUpdate, RojoTree,
};
#[test]
fn reify_folder() {
fn set_name_and_class_name() {
let mut redactions = RedactionMap::new();
let mut tree = empty_tree();
redactions.intern(tree.get_root_id());
let patch_set = PatchSet {
updated_instances: vec![PatchUpdate {
@@ -19,10 +25,12 @@ fn reify_folder() {
..Default::default()
};
let _applied_patch_set = apply_patch_set(&mut tree, patch_set);
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
// TODO: Snapshot tree, requires RojoTree: Serialize (but not Deserialize!)
let applied_patch_value = redactions.redacted_yaml(applied_patch_set);
assert_yaml_snapshot!(applied_patch_value);
}
fn empty_tree() -> RojoTree {

View File

@@ -0,0 +1,12 @@
---
source: src/snapshot/tests/apply.rs
expression: applied_patch_value
---
removed: []
added: []
updated:
- id: id-1
changed_name: "Hello, world!"
changed_class_name: Folder
changed_properties: {}
changed_metadata: ~