Skip to content

Commit

Permalink
tests: simplify job_count code
Browse files Browse the repository at this point in the history
  • Loading branch information
leo91000 committed Feb 4, 2024
1 parent b846217 commit 3d0af07
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions tests/run_task_list_once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ async fn it_should_run_jobs() {
let worker = test_db
.create_worker_options()
.define_raw_job("job3", |_, _: serde_json::Value| async move {
let job_count = JOB3_CALL_COUNT.get_or_init(|| Mutex::new(0));
let mut job_count = job_count.lock().await;
let mut job_count = JOB3_CALL_COUNT.get_or_init(|| Mutex::new(0)).lock().await;
*job_count += 1;
Ok(()) as Result<(), ()>
})
.define_raw_job("job2", |_, _: serde_json::Value| async move {
let job_count = JOB2_CALL_COUNT.get_or_init(|| Mutex::new(0));
let mut job_count = job_count.lock().await;
let mut job_count = JOB2_CALL_COUNT.get_or_init(|| Mutex::new(0)).lock().await;
*job_count += 1;
Ok(()) as Result<(), ()>
})
Expand Down Expand Up @@ -83,8 +81,7 @@ async fn it_should_schedule_errors_for_retry() {
let worker = test_db
.create_worker_options()
.define_raw_job("job3", |_, _: serde_json::Value| async move {
let job_count = JOB3_CALL_COUNT.get_or_init(|| Mutex::new(0));
let mut job_count = job_count.lock().await;
let mut job_count = JOB3_CALL_COUNT.get_or_init(|| Mutex::new(0)).lock().await;
*job_count += 1;
Err("fail".to_string()) as Result<(), String>
})
Expand Down

0 comments on commit 3d0af07

Please sign in to comment.