Make .meta.json changes cause scripts to be updated

This commit is contained in:
Lucien Greathouse
2019-10-08 15:30:16 -07:00
parent fa817e3cdd
commit 13cb0a27a0
11 changed files with 178 additions and 1 deletions

View File

@@ -245,6 +245,69 @@ mod serve_session {
assert_yaml_snapshot!(view_tree(&session.tree(), &mut rm));
}
#[test]
fn script_with_meta() {
let mut imfs = Imfs::new(NoopFetcher);
imfs.debug_load_snapshot(
"/root",
ImfsSnapshot::dir(hashmap! {
"test.lua" => ImfsSnapshot::file("This is a test."),
"test.meta.json" => ImfsSnapshot::file(r#"{ "ignoreUnknownInstances": true }"#),
}),
);
let session = ServeSession::new(imfs, "/root", None);
let mut rm = RedactionMap::new();
assert_yaml_snapshot!(view_tree(&session.tree(), &mut rm));
}
#[test]
fn change_script_meta() {
let (state, fetcher) = TestFetcher::new();
state.load_snapshot(
"/root",
ImfsSnapshot::dir(hashmap! {
"test.lua" => ImfsSnapshot::file("This is a test."),
"test.meta.json" => ImfsSnapshot::file(r#"{ "ignoreUnknownInstances": true }"#),
}),
);
let imfs = Imfs::new(fetcher);
let session = ServeSession::new(imfs, "/root", None);
let mut redactions = RedactionMap::new();
assert_yaml_snapshot!(
"change_script_meta_before",
view_tree(&session.tree(), &mut redactions)
);
state.load_snapshot(
"/root/test.meta.json",
ImfsSnapshot::file(r#"{ "ignoreUnknownInstances": false }"#),
);
let receiver = Timeout::new(
session.message_queue().subscribe_any(),
Duration::from_millis(200),
);
state.raise_event(ImfsEvent::Modified(PathBuf::from("/root/test.meta.json")));
let mut rt = Runtime::new().unwrap();
let changes = rt.block_on(receiver).unwrap();
assert_yaml_snapshot!(
"change_script_meta_patch",
redactions.redacted_yaml(changes)
);
assert_yaml_snapshot!(
"change_script_meta_after",
view_tree(&session.tree(), &mut redactions)
);
}
#[test]
fn change_txt_file() {
let (state, fetcher) = TestFetcher::new();

View File

@@ -96,7 +96,7 @@ fn snapshot_lua_file<F: ImfsFetcher>(
let mut metadata = InstanceMetadata {
instigating_source: Some(entry.path().to_path_buf().into()),
relevant_paths: vec![entry.path().to_path_buf()],
relevant_paths: vec![entry.path().to_path_buf(), meta_path.clone()],
..Default::default()
};

View File

@@ -9,6 +9,7 @@ metadata:
Path: /foo.client.lua
relevant_paths:
- /foo.client.lua
- /foo.meta.json
name: foo
class_name: LocalScript
properties:

View File

@@ -9,6 +9,7 @@ metadata:
Path: /foo.lua
relevant_paths:
- /foo.lua
- /foo.meta.json
name: foo
class_name: ModuleScript
properties:

View File

@@ -9,6 +9,7 @@ metadata:
Path: /foo.lua
relevant_paths:
- /foo.lua
- /foo.meta.json
name: foo
class_name: ModuleScript
properties:

View File

@@ -9,6 +9,7 @@ metadata:
Path: /foo.server.lua
relevant_paths:
- /foo.server.lua
- /foo.meta.json
name: foo
class_name: Script
properties:

View File

@@ -9,6 +9,7 @@ metadata:
Path: /foo.server.lua
relevant_paths:
- /foo.server.lua
- /foo.meta.json
name: foo
class_name: Script
properties:

View File

@@ -0,0 +1,30 @@
---
source: src/serve_session.rs
expression: "view_tree(&session.tree(), &mut redactions)"
---
id: id-1
name: root
class_name: Folder
properties: {}
metadata:
ignore_unknown_instances: false
instigating_source:
Path: /root
relevant_paths:
- /root
children:
- id: id-2
name: test
class_name: ModuleScript
properties:
Source:
Type: String
Value: This is a test.
metadata:
ignore_unknown_instances: false
instigating_source:
Path: /root/test.lua
relevant_paths:
- /root/test.lua
- /root/test.meta.json
children: []

View File

@@ -0,0 +1,30 @@
---
source: src/serve_session.rs
expression: "view_tree(&session.tree(), &mut redactions)"
---
id: id-1
name: root
class_name: Folder
properties: {}
metadata:
ignore_unknown_instances: false
instigating_source:
Path: /root
relevant_paths:
- /root
children:
- id: id-2
name: test
class_name: ModuleScript
properties:
Source:
Type: String
Value: This is a test.
metadata:
ignore_unknown_instances: true
instigating_source:
Path: /root/test.lua
relevant_paths:
- /root/test.lua
- /root/test.meta.json
children: []

View File

@@ -0,0 +1,19 @@
---
source: src/serve_session.rs
expression: redactions.redacted_yaml(changes)
---
- 1
- - removed: []
added: []
updated:
- id: id-2
changed_name: ~
changed_class_name: ~
changed_properties: {}
changed_metadata:
ignore_unknown_instances: false
instigating_source:
Path: /root/test.lua
relevant_paths:
- /root/test.lua
- /root/test.meta.json

View File

@@ -0,0 +1,30 @@
---
source: src/serve_session.rs
expression: "view_tree(&session.tree(), &mut rm)"
---
id: id-1
name: root
class_name: Folder
properties: {}
metadata:
ignore_unknown_instances: false
instigating_source:
Path: /root
relevant_paths:
- /root
children:
- id: id-2
name: test
class_name: ModuleScript
properties:
Source:
Type: String
Value: This is a test.
metadata:
ignore_unknown_instances: true
instigating_source:
Path: /root/test.lua
relevant_paths:
- /root/test.lua
- /root/test.meta.json
children: []