Skip to content

Commit

Permalink
chore: add delay to some tests to make sure they always work as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
rubik committed Oct 11, 2019
1 parent d1128f2 commit 6a569c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions tests/consumer.rs
Expand Up @@ -2,6 +2,7 @@ use orizuru::Consumer;
use redis::{Commands, Value};
use rmp_serde::Serializer;
use serde::{Deserialize, Serialize};
use std::thread;
use std::time;
use uuid::Uuid;

Expand Down Expand Up @@ -155,6 +156,9 @@ fn one_heartbeat() {

#[test]
fn multiple_heartbeat() {
// ugly hack to ensure this test runs after the previous one, because Cargo
// runs them in parallel
thread::sleep(time::Duration::from_millis(300));
redis_fixture!(client, con, consumer, {
let _: () = con.del(consumer.heartbeats_key()).unwrap();

Expand Down
8 changes: 4 additions & 4 deletions tests/gc.rs
Expand Up @@ -2,9 +2,9 @@ use orizuru::{Consumer, GC};
use redis::{Commands, Value};
use rmp_serde::Serializer;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
use std::thread;
use std::time;
use uuid::Uuid;

#[macro_use]
mod test_utils;
Expand Down Expand Up @@ -57,10 +57,10 @@ fn collect_runs_with_a_consumer_and_no_jobs() {

#[test]
fn collect_runs_with_a_consumer_and_some_jobs() {
// ugly hack to ensure this test runs after the previous one, because Cargo
// runs them in parallel
thread::sleep(time::Duration::from_millis(300));
redis_fixture!(client, con, consumer, "g", gc, {
// ugly hack to ensure this test runs after the previous one, because Cargo
// runs them in parallel
thread::sleep(time::Duration::from_secs(1));
for i in 0..3 {
let _: () = con
.lpush(consumer.unacked_queue(), sample_job_payload(i))
Expand Down

0 comments on commit 6a569c5

Please sign in to comment.