Snapshot tests for JSON models

This commit is contained in:
Lucien Greathouse
2019-10-03 18:28:58 -07:00
parent 6ef832b3a9
commit 72d88200e4
2 changed files with 31 additions and 23 deletions

View File

@@ -50,7 +50,9 @@ impl SnapshotMiddleware for SnapshotJsonModel {
}
}
let snapshot = instance.core.into_snapshot(instance_name);
let mut snapshot = instance.core.into_snapshot(instance_name);
snapshot.metadata.contributing_paths = vec![entry.path().to_path_buf()];
Ok(Some(snapshot))
}
@@ -133,6 +135,7 @@ impl JsonModelCore {
mod test {
use super::*;
use insta::assert_yaml_snapshot;
use maplit::hashmap;
use rbx_dom_weak::RbxValue;
@@ -166,27 +169,6 @@ mod test {
.unwrap()
.unwrap();
assert_eq!(
instance_snapshot,
InstanceSnapshot {
snapshot_id: None,
metadata: Default::default(), // TODO
name: Cow::Borrowed("foo"),
class_name: Cow::Borrowed("IntValue"),
properties: hashmap! {
"Value".to_owned() => RbxValue::Int32 {
value: 5,
},
},
children: vec![InstanceSnapshot {
snapshot_id: None,
metadata: Default::default(), // TODO
name: Cow::Borrowed("The Child"),
class_name: Cow::Borrowed("StringValue"),
properties: HashMap::new(),
children: Vec::new(),
},],
}
);
assert_yaml_snapshot!(instance_snapshot);
}
}

View File

@@ -0,0 +1,26 @@
---
source: src/snapshot_middleware/json_model.rs
expression: instance_snapshot
---
snapshot_id: ~
metadata:
ignore_unknown_instances: false
contributing_paths:
- /foo.model.json
project_node: ~
name: foo
class_name: IntValue
properties:
Value:
Type: Int32
Value: 5
children:
- snapshot_id: ~
metadata:
ignore_unknown_instances: false
contributing_paths: []
project_node: ~
name: The Child
class_name: StringValue
properties: {}
children: []