usesuper::*;// RULE: a remembered folder policy cannot widen a process whose manifest forbids Personal genesis.#[test]fn genesis_none_cannot_be_widened_by_a_remembered_personal_policy() {let root = std::env::temp_dir().join(format!("cotton-genesis-policy-{}", std::process::id()));Genesis::Personal.keep(&root).unwrap(); assert_eq!(Genesis::at_under(&root, Genesis::None).unwrap(),Genesis::None ); assert_eq!(Genesis::at_under(&root, Genesis::Personal).unwrap(),Genesis::Personal ); std::fs::remove_dir_all(root).unwrap();}// RULE: genesis is a closed typed choice; an invalid value must never silently permit a Personal birth.#[test]fn the_manifest_decides_genesis() { assert_eq!(Genesis::of(None), Ok(Genesis::Personal));for (word, expected) in [("personal", Genesis::Personal), ("none", Genesis::None)] { assert_eq!(Genesis::of(Some(&serde_json::json!({"genesis": word}))),Ok(expected) ); }for wrong in [ serde_json::json!("no"), serde_json::json!(null), serde_json::json!(false), ] { assert!(Genesis::of(Some(&serde_json::json!({"genesis": wrong}))).is_err()); }}// RULE: a manifest's tools are the genesis set, and an id that is neither a// kit package nor a compiled built-in refuses the manifest at load — a// silent skip would found databases without a tool the app promised. Every// manifest the apps bundle must load, and no id is both kinds.#[test]fn a_manifest_names_only_tools_this_build_has() { assert_eq!(GenesisTools::of(None), Ok(GenesisTools::default()));let set = GenesisTools::of(Some(&serde_json::json!({"tools": ["people", "calls", "notebook"]}))).unwrap(); assert_eq!(set.packages(), vec!["people", "notebook"]); assert!(GenesisTools::of(Some(&serde_json::json!({"tools": ["no-such-tool"]}))).is_err()); assert!(GenesisTools::of(Some(&serde_json::json!({"tools": ["people", "people"]}))).is_err());for id in BUILT_IN_TOOLS { assert!(!crate::kit::ids().contains(id), "{id} is both a kit package and a built-in"); }let apps = cotton_store::manifest_dir().join("../../apps/cotton/App"); assert!(apps.is_dir(), "{} is missing — the shipped manifests this rule reads", apps.display());letmut manifests = vec![apps.join("CottonManifest/flavour.json")];for flavour in std::fs::read_dir(apps.join("Flavours")).unwrap() {// A folder that holds only an app's icons so far (Post, Sites before their shells) has no manifest yet.let path = flavour.unwrap().path().join("flavour.json");if path.is_file() { manifests.push(path); } }for path in manifests {let manifest: serde_json::Value = serde_json::from_slice(&std::fs::read(&path).unwrap()).unwrap();ifletErr(reason) = GenesisTools::of(Some(&manifest)) { panic!("{}: {reason}", path.display()); } }}