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.
37 lines
920 B
37 lines
920 B
3 years ago
|
use u_lib::{api::ClientHandler, models::*};
|
||
|
use uuid::Uuid;
|
||
|
|
||
|
pub struct RegisteredAgent {
|
||
|
pub uid: Uuid,
|
||
|
}
|
||
|
|
||
|
impl RegisteredAgent {
|
||
|
pub async fn unregister(self) {
|
||
|
let cli = ClientHandler::new(None);
|
||
|
cli.del(Some(self.uid)).await.unwrap();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#[fixture]
|
||
|
pub async fn register_agent() -> RegisteredAgent {
|
||
|
let cli = ClientHandler::new(None);
|
||
|
let agent_uid = Uuid::new_v4();
|
||
|
let resp = cli
|
||
|
.get_personal_jobs(Some(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(&vec![ExecResult::Agent(agent_data)])
|
||
|
.await
|
||
|
.unwrap();
|
||
|
RegisteredAgent { uid: agent_uid }
|
||
|
}
|