()
| 1499 | |
| 1500 | #[test] |
| 1501 | fn test_load_agents_from_dir() { |
| 1502 | let temp_dir = tempfile::tempdir().unwrap(); |
| 1503 | |
| 1504 | // Create a YAML agent file |
| 1505 | std::fs::write( |
| 1506 | temp_dir.path().join("agent1.yaml"), |
| 1507 | r#" |
| 1508 | name: yaml-agent |
| 1509 | description: Agent from YAML file |
| 1510 | "#, |
| 1511 | ) |
| 1512 | .unwrap(); |
| 1513 | |
| 1514 | // Create a Markdown agent file |
| 1515 | std::fs::write( |
| 1516 | temp_dir.path().join("agent2.md"), |
| 1517 | r#"--- |
| 1518 | name: md-agent |
| 1519 | description: Agent from Markdown file |
| 1520 | --- |
| 1521 | System prompt here |
| 1522 | "#, |
| 1523 | ) |
| 1524 | .unwrap(); |
| 1525 | |
| 1526 | // Create an invalid file (should be skipped) |
| 1527 | std::fs::write(temp_dir.path().join("invalid.yaml"), "not: valid: yaml: [").unwrap(); |
| 1528 | |
| 1529 | // Create a nested agent file (Claude-style directories are recursive) |
| 1530 | std::fs::create_dir_all(temp_dir.path().join("nested")).unwrap(); |
| 1531 | std::fs::write( |
| 1532 | temp_dir.path().join("nested").join("agent3.md"), |
| 1533 | r#"--- |
| 1534 | name: nested-agent |
| 1535 | description: Agent from nested Markdown file |
| 1536 | --- |
| 1537 | Nested prompt |
| 1538 | "#, |
| 1539 | ) |
| 1540 | .unwrap(); |
| 1541 | |
| 1542 | // Create a non-agent file (should be skipped) |
| 1543 | std::fs::write(temp_dir.path().join("readme.txt"), "Just a text file").unwrap(); |
| 1544 | |
| 1545 | let agents = load_agents_from_dir(temp_dir.path()); |
| 1546 | assert_eq!(agents.len(), 3); |
| 1547 | |
| 1548 | let names: Vec<&str> = agents.iter().map(|a| a.name.as_str()).collect(); |
| 1549 | assert!(names.contains(&"yaml-agent")); |
| 1550 | assert!(names.contains(&"md-agent")); |
| 1551 | assert!(names.contains(&"nested-agent")); |
| 1552 | } |
| 1553 | |
| 1554 | #[test] |
| 1555 | fn test_load_agents_from_nonexistent_dir() { |
nothing calls this directly
no test coverage detected