mirror of
https://github.com/Diggsey/sqlxmq.git
synced 2024-11-22 00:01:00 +00:00
parent
043774fba1
commit
b332b6d826
1 changed files with 15 additions and 4 deletions
19
src/lib.rs
19
src/lib.rs
|
@ -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) {
|
||||
|
@ -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")
|
||||
|
@ -561,7 +573,7 @@ mod tests {
|
|||
})
|
||||
.await;
|
||||
|
||||
let backoff = 200;
|
||||
let backoff = default_pause();
|
||||
|
||||
assert_eq!(counter.load(Ordering::SeqCst), 0);
|
||||
JobBuilder::new("foo")
|
||||
|
@ -579,7 +591,6 @@ mod tests {
|
|||
|
||||
// Second attempt
|
||||
pause_ms(backoff).await;
|
||||
pause().await;
|
||||
assert_eq!(counter.load(Ordering::SeqCst), 2);
|
||||
|
||||
// No more attempts
|
||||
|
|
Loading…
Reference in a new issue