Skip to content

Commit

Permalink
Ci tests (#42)
Browse files Browse the repository at this point in the history
* Increase pause during test runs in CI
  • Loading branch information
imbolc authored Jul 13, 2022
1 parent 043774f commit b332b6d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,20 @@ mod tests {
registry.runner(pool).run().await.unwrap()
}

fn is_ci() -> bool {
std::env::var("CI").ok().is_some()
}

fn default_pause() -> u64 {
if is_ci() {
1000
} else {
200
}
}

async fn pause() {
pause_ms(200).await;
pause_ms(default_pause()).await;
}

async fn pause_ms(ms: u64) {
Expand Down Expand Up @@ -513,7 +525,7 @@ mod tests {
let pool = &*test_pool().await;
let (_runner, counter) = test_job_runner(pool, move |_| async {}).await;

let backoff = 500;
let backoff = default_pause() + 300;

assert_eq!(counter.load(Ordering::SeqCst), 0);
JobBuilder::new("foo")
Expand Down Expand Up @@ -561,7 +573,7 @@ mod tests {
})
.await;

let backoff = 200;
let backoff = default_pause();

assert_eq!(counter.load(Ordering::SeqCst), 0);
JobBuilder::new("foo")
Expand All @@ -579,7 +591,6 @@ mod tests {

// Second attempt
pause_ms(backoff).await;
pause().await;
assert_eq!(counter.load(Ordering::SeqCst), 2);

// No more attempts
Expand Down

0 comments on commit b332b6d

Please sign in to comment.