Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make queue control tests use newly introduced Client::current_info #68

Merged
merged 4 commits into from
Jun 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions tests/real/community.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -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

Expand All @@ -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());
Expand Down Expand Up @@ -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

Expand All @@ -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());
Expand Down
Loading