Skip to content

Commit

Permalink
add: generic vacuum test for all storages
Browse files Browse the repository at this point in the history
  • Loading branch information
geofmureithi committed Jan 11, 2025
1 parent 3fc8d77 commit 9277b79
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/apalis-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,25 @@ pub mod test_utils {
// assert_eq!(res, 0);
t.vacuum().await.unwrap();
}
#[tokio::test]
async fn integration_test_storage_vacuum() {
let backend = $setup().await;
let service = apalis_test_service_fn(|request: Request<u32, _>| async move {
Ok::<_, io::Error>(request.args)
});
let (mut t, poller) = TestWrapper::new_with_service(backend, service);
tokio::spawn(poller);
let res = t.len().await.unwrap();
assert_eq!(res, 0); // No jobs
t.push(1).await.unwrap();
let res = t.len().await.unwrap();
assert_eq!(res, 1); // A job exists
let res = t.execute_next().await;
assert_eq!(res.1, Ok("1".to_owned()));
t.vacuum().await.unwrap();
let res = t.len().await.unwrap();
assert_eq!(res, 0); // After vacuuming, there should be nothing
}
};
}
}

0 comments on commit 9277b79

Please sign in to comment.