Ci tests (#42)

* Increase pause during test runs in CI
This commit is contained in:
Imbolc 2022-07-13 16:59:27 +03:00 committed by GitHub
parent 043774fba1
commit b332b6d826
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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