diff --git a/tests/steps/worker_steps.rs b/tests/steps/worker_steps.rs index 250b216..6dbb247 100644 --- a/tests/steps/worker_steps.rs +++ b/tests/steps/worker_steps.rs @@ -1,8 +1,10 @@ -#![allow( - clippy::expect_used, - clippy::unwrap_used, - reason = "simplify test output" -)] +//! Behavioural test steps for the worker task. +//! +//! These steps drive the Cucumber scenarios that verify the worker posts +//! queued comments and handles failures gracefully. +//! +//! Uses Wiremock to stub the GitHub Issues API and yaque for the on-disk queue. +//! See also: `test-support::octocrab_for()` and `yaque::channel()`. use std::sync::Arc; use std::time::Duration; @@ -34,6 +36,10 @@ impl std::fmt::Debug for WorkerWorld { } #[given("a queued comment request")] +#[expect( + clippy::expect_used, + reason = "test harness: fail fast on setup/IO errors" +)] async fn queued_request(world: &mut WorkerWorld) { let dir = TempDir::new().expect("tempdir"); let mut base = temp_config(&dir); @@ -76,10 +82,21 @@ async fn github_error(world: &mut WorkerWorld) { } #[when("the worker runs briefly")] +#[expect( + clippy::expect_used, + reason = "test harness: fail fast on world state errors" +)] async fn worker_runs(world: &mut WorkerWorld) { - let cfg = world.cfg.as_ref().unwrap().clone(); - let rx = world.receiver.take().unwrap(); - let server = world.server.as_ref().unwrap(); + let cfg = world + .cfg + .as_ref() + .expect("configuration should be initialised") + .clone(); + let rx = world + .receiver + .take() + .expect("receiver should be initialised"); + let server = world.server.as_ref().expect("server should be initialised"); let octocrab = octocrab_for(server); let handle = tokio::spawn(async move { let _ = run_worker(cfg, rx, octocrab).await; @@ -90,15 +107,37 @@ async fn worker_runs(world: &mut WorkerWorld) { } #[then("the comment is posted")] +#[expect( + clippy::expect_used, + reason = "test harness: expect wiremock state in assertion" +)] async fn comment_posted(world: &mut WorkerWorld) { - let server = world.server.as_ref().unwrap(); - assert!(!server.received_requests().await.unwrap().is_empty()); + let server = world.server.as_ref().expect("server should be initialised"); + assert!( + !server + .received_requests() + .await + .expect("inbound requests should be recorded") + .is_empty() + ); } #[then("the queue retains the job")] +#[expect( + clippy::expect_used, + reason = "test harness: expect fs state in assertion" +)] fn queue_retains(world: &mut WorkerWorld) { - let cfg = world.cfg.as_ref().unwrap(); - assert!(std::fs::read_dir(&cfg.queue_path).unwrap().count() > 0); + let cfg = world + .cfg + .as_ref() + .expect("configuration should be initialised"); + assert!( + std::fs::read_dir(&cfg.queue_path) + .expect("queue directory should be readable") + .count() + > 0 + ); } impl Drop for WorkerWorld {