mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-24 14:45:56 +00:00
Add contributing paths to SnapshotLua, switch to Insta tests
This commit is contained in:
@@ -5,7 +5,7 @@ use rbx_dom_weak::{RbxId, RbxTree, RbxValue};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
imfs::{FsResultExt, Imfs, ImfsEntry, ImfsFetcher},
|
imfs::{FsResultExt, Imfs, ImfsEntry, ImfsFetcher},
|
||||||
snapshot::InstanceSnapshot,
|
snapshot::{InstanceMetadata, InstanceSnapshot},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
@@ -90,7 +90,10 @@ fn snapshot_lua_file<F: ImfsFetcher>(
|
|||||||
|
|
||||||
Ok(Some(InstanceSnapshot {
|
Ok(Some(InstanceSnapshot {
|
||||||
snapshot_id: None,
|
snapshot_id: None,
|
||||||
metadata: Default::default(), // TODO
|
metadata: InstanceMetadata {
|
||||||
|
contributing_paths: vec![entry.path().to_path_buf()],
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
name: Cow::Owned(instance_name.to_owned()),
|
name: Cow::Owned(instance_name.to_owned()),
|
||||||
class_name: Cow::Borrowed(class_name),
|
class_name: Cow::Borrowed(class_name),
|
||||||
properties,
|
properties,
|
||||||
@@ -139,7 +142,7 @@ fn match_trailing<'a>(input: &'a str, trailer: &str) -> Option<&'a str> {
|
|||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use maplit::hashmap;
|
use insta::assert_yaml_snapshot;
|
||||||
|
|
||||||
use crate::imfs::{ImfsDebug, ImfsSnapshot, NoopFetcher};
|
use crate::imfs::{ImfsDebug, ImfsSnapshot, NoopFetcher};
|
||||||
|
|
||||||
@@ -153,16 +156,7 @@ mod test {
|
|||||||
let entry = imfs.get("/foo.lua").unwrap();
|
let entry = imfs.get("/foo.lua").unwrap();
|
||||||
let instance_snapshot = SnapshotLua::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
let instance_snapshot = SnapshotLua::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
||||||
|
|
||||||
assert_eq!(instance_snapshot.name, "foo");
|
assert_yaml_snapshot!(instance_snapshot);
|
||||||
assert_eq!(instance_snapshot.class_name, "ModuleScript");
|
|
||||||
assert_eq!(
|
|
||||||
instance_snapshot.properties,
|
|
||||||
hashmap! {
|
|
||||||
"Source".to_owned() => RbxValue::String {
|
|
||||||
value: "Hello there!".to_owned(),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -175,16 +169,7 @@ mod test {
|
|||||||
let entry = imfs.get("/foo.server.lua").unwrap();
|
let entry = imfs.get("/foo.server.lua").unwrap();
|
||||||
let instance_snapshot = SnapshotLua::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
let instance_snapshot = SnapshotLua::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
||||||
|
|
||||||
assert_eq!(instance_snapshot.name, "foo");
|
assert_yaml_snapshot!(instance_snapshot);
|
||||||
assert_eq!(instance_snapshot.class_name, "Script");
|
|
||||||
assert_eq!(
|
|
||||||
instance_snapshot.properties,
|
|
||||||
hashmap! {
|
|
||||||
"Source".to_owned() => RbxValue::String {
|
|
||||||
value: "Hello there!".to_owned(),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -197,15 +182,6 @@ mod test {
|
|||||||
let entry = imfs.get("/foo.client.lua").unwrap();
|
let entry = imfs.get("/foo.client.lua").unwrap();
|
||||||
let instance_snapshot = SnapshotLua::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
let instance_snapshot = SnapshotLua::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
||||||
|
|
||||||
assert_eq!(instance_snapshot.name, "foo");
|
assert_yaml_snapshot!(instance_snapshot);
|
||||||
assert_eq!(instance_snapshot.class_name, "LocalScript");
|
|
||||||
assert_eq!(
|
|
||||||
instance_snapshot.properties,
|
|
||||||
hashmap! {
|
|
||||||
"Source".to_owned() => RbxValue::String {
|
|
||||||
value: "Hello there!".to_owned(),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
source: src/snapshot_middleware/lua.rs
|
||||||
|
expression: instance_snapshot
|
||||||
|
---
|
||||||
|
snapshot_id: ~
|
||||||
|
metadata:
|
||||||
|
ignore_unknown_instances: false
|
||||||
|
contributing_paths:
|
||||||
|
- /foo.client.lua
|
||||||
|
project_node: ~
|
||||||
|
name: foo
|
||||||
|
class_name: LocalScript
|
||||||
|
properties:
|
||||||
|
Source:
|
||||||
|
Type: String
|
||||||
|
Value: Hello there!
|
||||||
|
children: []
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
source: src/snapshot_middleware/lua.rs
|
||||||
|
expression: instance_snapshot
|
||||||
|
---
|
||||||
|
snapshot_id: ~
|
||||||
|
metadata:
|
||||||
|
ignore_unknown_instances: false
|
||||||
|
contributing_paths:
|
||||||
|
- /foo.lua
|
||||||
|
project_node: ~
|
||||||
|
name: foo
|
||||||
|
class_name: ModuleScript
|
||||||
|
properties:
|
||||||
|
Source:
|
||||||
|
Type: String
|
||||||
|
Value: Hello there!
|
||||||
|
children: []
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
source: src/snapshot_middleware/lua.rs
|
||||||
|
expression: instance_snapshot
|
||||||
|
---
|
||||||
|
snapshot_id: ~
|
||||||
|
metadata:
|
||||||
|
ignore_unknown_instances: false
|
||||||
|
contributing_paths:
|
||||||
|
- /foo.server.lua
|
||||||
|
project_node: ~
|
||||||
|
name: foo
|
||||||
|
class_name: Script
|
||||||
|
properties:
|
||||||
|
Source:
|
||||||
|
Type: String
|
||||||
|
Value: Hello there!
|
||||||
|
children: []
|
||||||
Reference in New Issue
Block a user