| 3999 | use crate::cli::agent::Agent; |
| 4000 | |
| 4001 | async fn get_test_agents(os: &Os) -> Agents { |
| 4002 | const AGENT_PATH: &str = "/persona/TestAgent.json"; |
| 4003 | let mut agents = Agents::default(); |
| 4004 | let agent = Agent { |
| 4005 | path: Some(PathBuf::from(AGENT_PATH)), |
| 4006 | ..Default::default() |
| 4007 | }; |
| 4008 | if let Ok(false) = os.fs.try_exists(AGENT_PATH).await { |
| 4009 | let content = agent.to_str_pretty().expect("Failed to serialize test agent to file"); |
| 4010 | let agent_path = PathBuf::from(AGENT_PATH); |
| 4011 | os.fs |
| 4012 | .create_dir_all( |
| 4013 | agent_path |
| 4014 | .parent() |
| 4015 | .expect("Failed to obtain parent path for agent config"), |
| 4016 | ) |
| 4017 | .await |
| 4018 | .expect("Failed to create test agent dir"); |
| 4019 | os.fs |
| 4020 | .write(agent_path, &content) |
| 4021 | .await |
| 4022 | .expect("Failed to write test agent to file"); |
| 4023 | } |
| 4024 | agents.agents.insert("TestAgent".to_string(), agent); |
| 4025 | agents.switch("TestAgent").expect("Failed to switch agent"); |
| 4026 | agents |
| 4027 | } |
| 4028 | |
| 4029 | #[tokio::test] |
| 4030 | async fn test_flow() { |