concinnity_dev/command/
check.rs1use crate::check_at_path;
7use concinnity_cook::world::find_world_jsonl;
8
9pub fn check(json_path: &str) -> std::io::Result<()> {
14 let resolved;
15 let json_path = if !std::path::Path::new(json_path).exists() {
16 resolved = find_world_jsonl(None)?;
17 resolved.as_str()
18 } else {
19 json_path
20 };
21 check_at_path(json_path)
22}
23
24#[cfg(test)]
25mod tests {
26 use super::*;
27
28 #[test]
31 fn check_validates_an_explicit_existing_world() {
32 let dir = tempfile::tempdir().unwrap();
33 let path = dir.path().join("world.jsonl");
34 std::fs::write(
35 &path,
36 "{\"name\":\"phys\",\"type\":\"PhysicsConfig\",\"args\":{}}\n",
37 )
38 .unwrap();
39 check(path.to_str().unwrap()).unwrap();
40 }
41
42 #[test]
43 fn check_reports_an_invalid_explicit_world() {
44 let dir = tempfile::tempdir().unwrap();
45 let path = dir.path().join("world.jsonl");
46 std::fs::write(
47 &path,
48 "{\"name\":\"x\",\"type\":\"NotARealAssetType\",\"args\":{}}\n",
49 )
50 .unwrap();
51 assert!(check(path.to_str().unwrap()).is_err());
52 }
53}