diff options
Diffstat (limited to 'tests/dispatch.rs')
| -rw-r--r-- | tests/dispatch.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/dispatch.rs b/tests/dispatch.rs index c70dd6b..6721fc8 100644 --- a/tests/dispatch.rs +++ b/tests/dispatch.rs @@ -103,7 +103,7 @@ fn an_expired_lease_is_requeued_and_its_running_step_marked_interrupted() { // A fresh dispatcher (as after a restart) reaps it before claiming anything. let reaped = builds::reap_expired(&env.db).unwrap(); assert_eq!(reaped, 1, "the expired lease was not requeued"); - assert_eq!(builds::get(&env.db, &id).unwrap().unwrap().state, build_state::QUEUED); + assert_eq!(builds::get(&env.db, &id).unwrap().unwrap().state, BuildState::Queued); assert_eq!( builds::step_status(&env.db, &id, "build").unwrap().as_deref(), Some("interrupted"), @@ -129,7 +129,7 @@ fn a_newer_approval_cancels_an_in_flight_build_at_the_step_boundary() { // run() honours it at the step boundary rather than mid-step. let out = pipeline::run(&env.cfg, &env.db, &id).unwrap(); assert!(matches!(out, pipeline::Outcome::Cancelled), "run ignored the cancellation"); - assert_eq!(builds::get(&env.db, &id).unwrap().unwrap().state, build_state::CANCELLED); + assert_eq!(builds::get(&env.db, &id).unwrap().unwrap().state, BuildState::Cancelled); } #[test] @@ -140,9 +140,9 @@ fn a_deterministic_build_failure_is_not_retried() { let (env, _fx) = env_with_fixture("build-fails"); let id = queued_build(&env, "build-fails"); let pool = dispatch::Pool::spawn(Arc::new(env.cfg.clone()), env.db.clone()); - let state = wait_for(&env, &id, &["failed", "succeeded"]); + let state = wait_for(&env, &id, &[BuildState::Failed, BuildState::Succeeded]); pool.shutdown(); - assert_eq!(state, build_state::FAILED, "a deterministic failure should not succeed"); + assert_eq!(state, BuildState::Failed, "a deterministic failure should not succeed"); let b = builds::get(&env.db, &id).unwrap().unwrap(); assert_eq!(b.attempt, 1, "a deterministic failure must not be retried"); assert!(b.error.unwrap_or_default().contains("build"), "no step named in the error"); @@ -165,7 +165,7 @@ fn a_transient_failure_is_retried_up_to_the_cap() { // attempt count reaching the cap with the build left failed. let b = wait_attempt(&env, &id, 3); pool.shutdown(); - assert_eq!(b.state, build_state::FAILED); + assert_eq!(b.state, BuildState::Failed); assert_eq!(b.attempt, 3, "a transient failure should retry up to the cap"); } @@ -177,9 +177,9 @@ fn the_pool_takes_a_queued_build_all_the_way_to_publication() { let id = queued_build(&env, "plain-make"); let cfg = Arc::new(env.cfg.clone()); let pool = dispatch::Pool::spawn(cfg, env.db.clone()); - let state = wait_for(&env, &id, &["succeeded", "failed"]); + let state = wait_for(&env, &id, &[BuildState::Succeeded, BuildState::Failed]); pool.shutdown(); - assert_eq!(state, build_state::SUCCEEDED, "the pool did not finish the build"); + assert_eq!(state, BuildState::Succeeded, "the pool did not finish the build"); assert!(db::accepted_release(&env.db, "plain-make").unwrap().is_some(), "nothing was published"); assert_eq!(db::index_version(&env.db, "plain-make").unwrap().as_deref(), Some("1.0-1")); } @@ -218,9 +218,9 @@ fn a_reaped_build_resumes_at_the_next_incomplete_step_with_no_duplicate_work() { ); let pool = dispatch::Pool::spawn(Arc::new(env.cfg.clone()), env.db.clone()); - let state = wait_for(&env, &id, &["succeeded", "failed"]); + let state = wait_for(&env, &id, &[BuildState::Succeeded, BuildState::Failed]); pool.shutdown(); - assert_eq!(state, build_state::SUCCEEDED, "the resumed build did not finish"); + assert_eq!(state, BuildState::Succeeded, "the resumed build did not finish"); assert_eq!( aur_build::shims::called_with(&env.cfg.shim_dir.clone().unwrap(), "makechrootpkg", ""), @@ -255,7 +255,7 @@ fn queued_candidate(env: &Env, name: &str) -> CandidateRow { fn wait_attempt(env: &Env, id: &str, n: i64) -> builds::BuildRow { for _ in 0..600 { if let Some(b) = builds::get(&env.db, id).unwrap() { - if b.attempt >= n && b.state == build_state::FAILED { + if b.attempt >= n && b.state == BuildState::Failed { return b; } } @@ -265,10 +265,10 @@ fn wait_attempt(env: &Env, id: &str, n: i64) -> builds::BuildRow { } /// Poll until the build reaches one of `want` (or the test gives up). -fn wait_for(env: &Env, id: &str, want: &[&str]) -> String { +fn wait_for(env: &Env, id: &str, want: &[BuildState]) -> BuildState { for _ in 0..600 { if let Some(b) = builds::get(&env.db, id).unwrap() { - if want.contains(&b.state.as_str()) { + if want.contains(&b.state) { return b.state; } } |
