diff --git a/tests/real/community.rs b/tests/real/community.rs index bca63e41..66755421 100644 --- a/tests/real/community.rs +++ b/tests/real/community.rs @@ -1,7 +1,8 @@ use crate::{assert_gte, skip_check}; use faktory::{Client, Job, JobBuilder, JobId, Worker, WorkerBuilder, WorkerId}; use serde_json::Value; -use std::{io, sync}; +use std::{io, sync, time::Duration}; +use tokio::time as tokio_time; #[tokio::test(flavor = "multi_thread")] async fn hello_client() { @@ -118,6 +119,9 @@ async fn server_state() { .await .unwrap(); + // let's give Faktory a second to get updated + tokio_time::sleep(Duration::from_secs(1)).await; + // we only pushed 1 job on this queue let server_state = client.current_info().await.unwrap(); assert_eq!(*server_state.data.queues.get(local).unwrap(), 1); @@ -159,16 +163,15 @@ async fn server_state() { server_state.data.total_processed ); - // Uncomment when `Client::queue_remove` is delivered: - // client.queue_remove(&[local]).await.unwrap(); - // assert!(client - // .current_info() - // .await - // .unwrap() - // .data - // .queues - // .get(local) - // .is_none()); + client.queue_remove(&[local]).await.unwrap(); + assert!(client + .current_info() + .await + .unwrap() + .data + .queues + .get(local) + .is_none()); } #[tokio::test(flavor = "multi_thread")] @@ -336,8 +339,8 @@ async fn queue_control_actions() { assert!(rx.try_recv().is_ok()); // let's inspect the sever state - let server_state = client.info().await.unwrap(); - let queues = &server_state.get("faktory").unwrap().get("queues").unwrap(); + let server_state = client.current_info().await.unwrap(); + let queues = &server_state.data.queues; assert_eq!(*queues.get(local_1).unwrap(), 1); // 1 job remaining assert_eq!(*queues.get(local_2).unwrap(), 1); // also 1 job remaining @@ -351,8 +354,8 @@ async fn queue_control_actions() { assert!(!rx.try_recv().is_ok()); // let's inspect the sever state again - let server_state = client.info().await.unwrap(); - let queues = &server_state.get("faktory").unwrap().get("queues").unwrap(); + let server_state = client.current_info().await.unwrap(); + let queues = &server_state.data.queues; // our queue are not even mentioned in the server report: assert!(queues.get(local_1).is_none()); assert!(queues.get(local_2).is_none()); @@ -418,8 +421,8 @@ async fn queue_control_actions_wildcard() { assert!(rx.try_recv().is_ok()); // let's inspect the sever state - let server_state = client.info().await.unwrap(); - let queues = &server_state.get("faktory").unwrap().get("queues").unwrap(); + let server_state = client.current_info().await.unwrap(); + let queues = &server_state.data.queues; assert_eq!(*queues.get(local_1).unwrap(), 1); // 1 job remaining assert_eq!(*queues.get(local_2).unwrap(), 1); // also 1 job remaining @@ -433,9 +436,8 @@ async fn queue_control_actions_wildcard() { assert!(!rx.try_recv().is_ok()); // let's inspect the sever state again - let server_state = client.info().await.unwrap(); - let queues = &server_state.get("faktory").unwrap().get("queues").unwrap(); - + let server_state = client.current_info().await.unwrap(); + let queues = &server_state.data.queues; // our queue are not even mentioned in the server report: assert!(queues.get(local_1).is_none()); assert!(queues.get(local_2).is_none());