mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-20 20:55:50 +00:00
Port project file tests to use insta
This commit is contained in:
@@ -173,8 +173,8 @@ fn snapshot_project_node<F: ImfsFetcher>(
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
use insta::assert_yaml_snapshot;
|
||||
use maplit::hashmap;
|
||||
use rbx_dom_weak::RbxValue;
|
||||
|
||||
use crate::imfs::{ImfsDebug, ImfsSnapshot, NoopFetcher};
|
||||
|
||||
@@ -201,10 +201,7 @@ mod test {
|
||||
.expect("snapshot error")
|
||||
.expect("snapshot returned no instances");
|
||||
|
||||
assert_eq!(instance_snapshot.name, "indirect-project");
|
||||
assert_eq!(instance_snapshot.class_name, "Folder");
|
||||
assert_eq!(instance_snapshot.properties, HashMap::new());
|
||||
assert_eq!(instance_snapshot.children, Vec::new());
|
||||
assert_yaml_snapshot!(instance_snapshot);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -230,10 +227,7 @@ mod test {
|
||||
.expect("snapshot error")
|
||||
.expect("snapshot returned no instances");
|
||||
|
||||
assert_eq!(instance_snapshot.name, "direct-project");
|
||||
assert_eq!(instance_snapshot.class_name, "Model");
|
||||
assert_eq!(instance_snapshot.properties, HashMap::new());
|
||||
assert_eq!(instance_snapshot.children, Vec::new());
|
||||
assert_yaml_snapshot!(instance_snapshot);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -265,17 +259,7 @@ mod test {
|
||||
.expect("snapshot error")
|
||||
.expect("snapshot returned no instances");
|
||||
|
||||
assert_eq!(instance_snapshot.name, "resolved-properties");
|
||||
assert_eq!(instance_snapshot.class_name, "StringValue");
|
||||
assert_eq!(
|
||||
instance_snapshot.properties,
|
||||
hashmap! {
|
||||
"Value".to_owned() => RbxValue::String {
|
||||
value: "Hello, world!".to_owned(),
|
||||
},
|
||||
}
|
||||
);
|
||||
assert_eq!(instance_snapshot.children, Vec::new());
|
||||
assert_yaml_snapshot!(instance_snapshot);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -304,17 +288,7 @@ mod test {
|
||||
.expect("snapshot error")
|
||||
.expect("snapshot returned no instances");
|
||||
|
||||
assert_eq!(instance_snapshot.name, "unresolved-properties");
|
||||
assert_eq!(instance_snapshot.class_name, "StringValue");
|
||||
assert_eq!(
|
||||
instance_snapshot.properties,
|
||||
hashmap! {
|
||||
"Value".to_owned() => RbxValue::String {
|
||||
value: "Hi!".to_owned(),
|
||||
},
|
||||
}
|
||||
);
|
||||
assert_eq!(instance_snapshot.children, Vec::new());
|
||||
assert_yaml_snapshot!(instance_snapshot);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -344,16 +318,7 @@ mod test {
|
||||
.expect("snapshot error")
|
||||
.expect("snapshot returned no instances");
|
||||
|
||||
assert_eq!(instance_snapshot.name, "children");
|
||||
assert_eq!(instance_snapshot.class_name, "Folder");
|
||||
assert_eq!(instance_snapshot.properties, HashMap::new());
|
||||
assert_eq!(instance_snapshot.children.len(), 1);
|
||||
|
||||
let child = &instance_snapshot.children[0];
|
||||
assert_eq!(child.name, "Child");
|
||||
assert_eq!(child.class_name, "Model");
|
||||
assert_eq!(child.properties, HashMap::new());
|
||||
assert_eq!(child.children, Vec::new());
|
||||
assert_yaml_snapshot!(instance_snapshot);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -380,17 +345,7 @@ mod test {
|
||||
.expect("snapshot error")
|
||||
.expect("snapshot returned no instances");
|
||||
|
||||
assert_eq!(instance_snapshot.name, "path-project");
|
||||
assert_eq!(instance_snapshot.class_name, "StringValue");
|
||||
assert_eq!(
|
||||
instance_snapshot.properties,
|
||||
hashmap! {
|
||||
"Value".to_owned() => RbxValue::String {
|
||||
value: "Hello, world!".to_owned(),
|
||||
},
|
||||
}
|
||||
);
|
||||
assert_eq!(instance_snapshot.children, Vec::new());
|
||||
assert_yaml_snapshot!(instance_snapshot);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -424,10 +379,7 @@ mod test {
|
||||
.expect("snapshot error")
|
||||
.expect("snapshot returned no instances");
|
||||
|
||||
assert_eq!(instance_snapshot.name, "path-project");
|
||||
assert_eq!(instance_snapshot.class_name, "Model");
|
||||
assert_eq!(instance_snapshot.properties, HashMap::new());
|
||||
assert_eq!(instance_snapshot.children, Vec::new());
|
||||
assert_yaml_snapshot!(instance_snapshot);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -465,16 +417,7 @@ mod test {
|
||||
.expect("snapshot error")
|
||||
.expect("snapshot returned no instances");
|
||||
|
||||
assert_eq!(instance_snapshot.name, "path-child-project");
|
||||
assert_eq!(instance_snapshot.class_name, "Folder");
|
||||
assert_eq!(instance_snapshot.properties, HashMap::new());
|
||||
assert_eq!(instance_snapshot.children.len(), 1);
|
||||
|
||||
let child = &instance_snapshot.children[0];
|
||||
assert_eq!(child.name, "SomeChild");
|
||||
assert_eq!(child.class_name, "Model");
|
||||
assert_eq!(child.properties, HashMap::new());
|
||||
assert_eq!(child.children, Vec::new());
|
||||
assert_yaml_snapshot!(instance_snapshot);
|
||||
}
|
||||
|
||||
/// Ensures that if a property is defined both in the resulting instance
|
||||
@@ -517,16 +460,6 @@ mod test {
|
||||
.expect("snapshot error")
|
||||
.expect("snapshot returned no instances");
|
||||
|
||||
assert_eq!(instance_snapshot.name, "path-property-override");
|
||||
assert_eq!(instance_snapshot.class_name, "StringValue");
|
||||
assert_eq!(
|
||||
instance_snapshot.properties,
|
||||
hashmap! {
|
||||
"Value".to_owned() => RbxValue::String {
|
||||
value: "Changed".to_owned(),
|
||||
},
|
||||
}
|
||||
);
|
||||
assert_eq!(instance_snapshot.children, Vec::new());
|
||||
assert_yaml_snapshot!(instance_snapshot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
source: src/snapshot_middleware/project.rs
|
||||
expression: instance_snapshot
|
||||
---
|
||||
snapshot_id: ~
|
||||
metadata:
|
||||
ignore_unknown_instances: true
|
||||
contributing_paths:
|
||||
- /foo/hello.project.json
|
||||
project_node: ~
|
||||
name: direct-project
|
||||
class_name: Model
|
||||
properties: {}
|
||||
children: []
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
source: src/snapshot_middleware/project.rs
|
||||
expression: instance_snapshot
|
||||
---
|
||||
snapshot_id: ~
|
||||
metadata:
|
||||
ignore_unknown_instances: true
|
||||
contributing_paths:
|
||||
- /foo/default.project.json
|
||||
project_node: ~
|
||||
name: indirect-project
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
children: []
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
source: src/snapshot_middleware/project.rs
|
||||
expression: instance_snapshot
|
||||
---
|
||||
snapshot_id: ~
|
||||
metadata:
|
||||
ignore_unknown_instances: true
|
||||
contributing_paths:
|
||||
- /foo/default.project.json
|
||||
- /foo/other.project.json
|
||||
project_node: ~
|
||||
name: path-property-override
|
||||
class_name: StringValue
|
||||
properties:
|
||||
Value:
|
||||
Type: String
|
||||
Value: Changed
|
||||
children: []
|
||||
@@ -0,0 +1,23 @@
|
||||
---
|
||||
source: src/snapshot_middleware/project.rs
|
||||
expression: instance_snapshot
|
||||
---
|
||||
snapshot_id: ~
|
||||
metadata:
|
||||
ignore_unknown_instances: true
|
||||
contributing_paths:
|
||||
- /foo/default.project.json
|
||||
project_node: ~
|
||||
name: children
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
children:
|
||||
- snapshot_id: ~
|
||||
metadata:
|
||||
ignore_unknown_instances: true
|
||||
contributing_paths: []
|
||||
project_node: ~
|
||||
name: Child
|
||||
class_name: Model
|
||||
properties: {}
|
||||
children: []
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
source: src/snapshot_middleware/project.rs
|
||||
expression: instance_snapshot
|
||||
---
|
||||
snapshot_id: ~
|
||||
metadata:
|
||||
ignore_unknown_instances: true
|
||||
contributing_paths:
|
||||
- /foo/default.project.json
|
||||
- /foo/other.project.json
|
||||
project_node: ~
|
||||
name: path-project
|
||||
class_name: Model
|
||||
properties: {}
|
||||
children: []
|
||||
@@ -0,0 +1,24 @@
|
||||
---
|
||||
source: src/snapshot_middleware/project.rs
|
||||
expression: instance_snapshot
|
||||
---
|
||||
snapshot_id: ~
|
||||
metadata:
|
||||
ignore_unknown_instances: true
|
||||
contributing_paths:
|
||||
- /foo/default.project.json
|
||||
- /foo/other.project.json
|
||||
project_node: ~
|
||||
name: path-child-project
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
children:
|
||||
- snapshot_id: ~
|
||||
metadata:
|
||||
ignore_unknown_instances: true
|
||||
contributing_paths: []
|
||||
project_node: ~
|
||||
name: SomeChild
|
||||
class_name: Model
|
||||
properties: {}
|
||||
children: []
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
source: src/snapshot_middleware/project.rs
|
||||
expression: instance_snapshot
|
||||
---
|
||||
snapshot_id: ~
|
||||
metadata:
|
||||
ignore_unknown_instances: false
|
||||
contributing_paths:
|
||||
- /foo/default.project.json
|
||||
- /foo/other.txt
|
||||
project_node: ~
|
||||
name: path-project
|
||||
class_name: StringValue
|
||||
properties:
|
||||
Value:
|
||||
Type: String
|
||||
Value: "Hello, world!"
|
||||
children: []
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
source: src/snapshot_middleware/project.rs
|
||||
expression: instance_snapshot
|
||||
---
|
||||
snapshot_id: ~
|
||||
metadata:
|
||||
ignore_unknown_instances: true
|
||||
contributing_paths:
|
||||
- /foo/default.project.json
|
||||
project_node: ~
|
||||
name: resolved-properties
|
||||
class_name: StringValue
|
||||
properties:
|
||||
Value:
|
||||
Type: String
|
||||
Value: "Hello, world!"
|
||||
children: []
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
source: src/snapshot_middleware/project.rs
|
||||
expression: instance_snapshot
|
||||
---
|
||||
snapshot_id: ~
|
||||
metadata:
|
||||
ignore_unknown_instances: true
|
||||
contributing_paths:
|
||||
- /foo/default.project.json
|
||||
project_node: ~
|
||||
name: unresolved-properties
|
||||
class_name: StringValue
|
||||
properties:
|
||||
Value:
|
||||
Type: String
|
||||
Value: Hi!
|
||||
children: []
|
||||
Reference in New Issue
Block a user