forked from rojo-rbx/rojo
Do not validate .model.json files with no content/whitespace only (#420)
* Ignore empty/whitespace-only model.json files
* Ignore no return value from model.json files during snapshot
* Use str::from_utf8 instead of String::from_utf8
* Revert "Ignore no return value from model.json files during snapshot"
This reverts commit 0aef16e30a.
* Add test for empty .model.json files
* Change empty .model.json check method
Co-authored-by: Lucien Greathouse <me@lpghatguy.com>
* Format code with cargo fmt
* Use raw string instead
Co-authored-by: Lucien Greathouse <me@lpghatguy.com>
This commit is contained in:
@@ -186,3 +186,37 @@ fn move_folder_of_stuff() {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_json_model() {
|
||||
run_serve_test("empty_json_model", |session, mut redactions| {
|
||||
let info = session.get_api_rojo().unwrap();
|
||||
let root_id = info.root_instance_id;
|
||||
|
||||
assert_yaml_snapshot!("empty_json_model_info", redactions.redacted_yaml(info));
|
||||
|
||||
let read_response = session.get_api_read(root_id).unwrap();
|
||||
assert_yaml_snapshot!(
|
||||
"empty_json_model_all",
|
||||
read_response.intern_and_redact(&mut redactions, root_id)
|
||||
);
|
||||
|
||||
fs::write(
|
||||
session.path().join("src/test.model.json"),
|
||||
r#"{"ClassName": "Model"}"#,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let subscribe_response = session.get_api_subscribe(0).unwrap();
|
||||
assert_yaml_snapshot!(
|
||||
"empty_json_model_subscribe",
|
||||
subscribe_response.intern_and_redact(&mut redactions, ())
|
||||
);
|
||||
|
||||
let read_response = session.get_api_read(root_id).unwrap();
|
||||
assert_yaml_snapshot!(
|
||||
"empty_json_model_all-2",
|
||||
read_response.intern_and_redact(&mut redactions, root_id)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user