use eidetica::{Entry, constants::ROOT, entry::ID};
use super::helpers::*;
#[test]
fn test_entry_creation() {
let root = "test_root";
let entry = create_entry_with_parents(root, &["parent1"]);
assert_eq!(entry.root(), ID::from_bytes(root));
assert!(!entry.is_root());
assert_has_parents(&entry, &["parent1"]); }
#[test]
fn test_entry_toplevel_creation() {
let entry = create_root_entry();
assert!(entry.root().is_empty());
assert!(entry.is_root());
assert!(entry.in_subtree(ROOT)); }
#[test]
fn test_in_tree_and_subtree() {
let root = "test_root_subtrees";
let entry = create_entry_with_subtree(root, "subtree1", "subtree_data");
assert!(entry.in_tree(""));
assert!(entry.in_tree(entry.id())); assert!(!entry.in_tree("other_tree"));
assert!(entry.in_subtree("subtree1"));
assert!(!entry.in_subtree("non_existent_subtree"));
}
#[test]
fn test_entry_parents() {
let root = "test_root_parents";
let entry_with_parents = create_entry_with_parents(root, &["parent1", "parent2"]);
assert_has_parents(&entry_with_parents, &["parent1", "parent2"]);
let subtree_name = "subtree1";
let subtree_data = "subtree_data";
let entry_with_subtree_parents =
create_entry_with_subtree_parents(root, subtree_name, subtree_data, &["subtree_parent"]);
assert_subtree_has_parents(
&entry_with_subtree_parents,
subtree_name,
&["subtree_parent"],
);
let mut builder = Entry::builder(ID::from_bytes(root));
builder.set_parents_mut(vec![ID::from_bytes("parent1"), ID::from_bytes("parent2")]);
builder.set_subtree_data_mut(subtree_name, subtree_data);
builder.set_subtree_parents_mut(subtree_name, vec![ID::from_bytes("subtree_parent")]);
let complex_entry = builder
.build()
.expect("Complex entry should build successfully");
assert_has_parents(&complex_entry, &["parent1", "parent2"]);
assert_subtree_has_parents(&complex_entry, subtree_name, &["subtree_parent"]);
}