// Test script for Project Rhai integration print("--- Testing Project Rhai Integration ---"); // Create a new project let p1 = new_project() .name("Project Alpha") .description("This is the first test project.") .owner_id(101) .add_member_id(102) .add_member_id(103) .member_ids([201, 202, 203]) // Test setting multiple IDs .add_tag("important") .add_tag("rhai_test") .tags(["core", "feature_test"]) // Test setting multiple tags .status(Status::InProgress) .priority(Priority::High) .item_type(ItemType::Feature) .add_base_comment(1001); print("Created project p1: " + p1); print("p1.name: " + p1.name); print("p1.description: " + p1.description); print("p1.owner_id: " + p1.owner_id); print("p1.member_ids: " + p1.member_ids); print("p1.tags: " + p1.tags); print(`p1.status: ${p1.status.to_string()}`); print(`p1.priority: ${p1.priority.to_string()}`); print(`p1.item_type: ${p1.item_type.to_string()}`); print("p1.id: " + p1.id); print("p1.created_at: " + p1.created_at); print("p1.modified_at: " + p1.modified_at); print("p1.comments: " + p1.comments); // Save to DB try { set_project(p1); print("Project p1 saved successfully."); } catch (err) { print("Error saving project p1: " + err); } // Retrieve from DB try { let retrieved_p1 = get_project_by_id(1); if retrieved_p1 != () { // Check if Some(project) was returned (None becomes '()') print("Retrieved project by ID 1: " + retrieved_p1); print("Retrieved project name: " + retrieved_p1.name); print("Retrieved project tags: " + retrieved_p1.tags); } else { print("Project with ID 1 not found."); } } catch (err) { print("Error retrieving project by ID 1: " + err); } // Test non-existent project try { let non_existent_project = get_project_by_id(999); if non_existent_project != () { print("Error: Found non-existent project 999: " + non_existent_project); } else { print("Correctly did not find project with ID 999."); } } catch (err) { print("Error checking for non-existent project: " + err); } print("--- Project Rhai Integration Test Complete ---");