You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
964 B

use crate::helpers::ENV;
use u_lib::{api::ClientHandler, messaging::Reportable, models::*};
use uuid::Uuid;
pub struct RegisteredAgent {
pub uid: Uuid,
}
impl RegisteredAgent {
pub async fn unregister(self) {
let cli = ClientHandler::new(&ENV.u_server, None);
cli.del(self.uid).await.unwrap();
}
}
#[fixture]
pub async fn register_agent() -> RegisteredAgent {
let cli = ClientHandler::new(&ENV.u_server, None);
let agent_uid = Uuid::new_v4();
let resp = cli
.get_personal_jobs(agent_uid)
.await
.unwrap()
.pop()
.unwrap();
let job_id = resp.job_id;
let resp = cli.get_jobs(Some(job_id)).await.unwrap().pop().unwrap();
assert_eq!(resp.alias, Some("agent_hello".to_string()));
let agent_data = Agent {
id: agent_uid,
..Default::default()
};
cli.report(&[Reportable::Agent(agent_data)]).await.unwrap();
RegisteredAgent { uid: agent_uid }
}