|
|
|
use super::connections::*;
|
|
|
|
use super::run_async;
|
|
|
|
use u_lib::{api::HttpClient, messaging::Reportable, models::*, types::Id};
|
|
|
|
|
|
|
|
pub struct RegisteredAgent {
|
|
|
|
pub id: Id,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[fixture]
|
|
|
|
#[once]
|
|
|
|
pub fn registered_agent(client: &HttpClient) -> RegisteredAgent {
|
|
|
|
run_async(async {
|
|
|
|
let agent = Agent::with_current_platform();
|
|
|
|
let agent_id = agent.id;
|
|
|
|
println!("registering agent {agent_id}");
|
|
|
|
debug!("registering agent1 {agent_id}");
|
|
|
|
let resp = client
|
|
|
|
.get_personal_jobs(agent_id)
|
|
|
|
.await
|
|
|
|
.unwrap()
|
|
|
|
.pop()
|
|
|
|
.unwrap();
|
|
|
|
let job_id = resp.job_id;
|
|
|
|
let job = client.get_job(job_id, Brief::No).await.unwrap();
|
|
|
|
|
|
|
|
assert_eq!(job.meta.alias, Some("agent_hello".to_string()));
|
|
|
|
|
|
|
|
let mut agent_data = AssignedJob::from(&PreparedJob { job, ids: resp });
|
|
|
|
agent_data.set_result(&agent);
|
|
|
|
|
|
|
|
client
|
|
|
|
.report([Reportable::Assigned(agent_data)])
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
RegisteredAgent { id: agent_id }
|
|
|
|
})
|
|
|
|
}
|