From 420feb257bcb136aa3ffc208c7162a57b03aafc4 Mon Sep 17 00:00:00 2001 From: Leynos Date: Fri, 8 Aug 2025 22:51:58 +0100 Subject: [PATCH 1/3] Use expect instead of allow in worker steps --- tests/steps/worker_steps.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/steps/worker_steps.rs b/tests/steps/worker_steps.rs index 250b216..ac2c4f1 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. + +#![expect(clippy::expect_used, reason = "simplify test output")] +#![expect(clippy::unwrap_used, reason = "simplify test output")] use std::sync::Arc; use std::time::Duration; From 4cb0307913988f3ce750399935790da354289ba3 Mon Sep 17 00:00:00 2001 From: Leynos Date: Mon, 11 Aug 2025 19:11:03 +0100 Subject: [PATCH 2/3] Use expect over unwrap in worker steps --- tests/steps/worker_steps.rs | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/tests/steps/worker_steps.rs b/tests/steps/worker_steps.rs index ac2c4f1..212985b 100644 --- a/tests/steps/worker_steps.rs +++ b/tests/steps/worker_steps.rs @@ -4,7 +4,6 @@ //! queued comments and handles failures gracefully. #![expect(clippy::expect_used, reason = "simplify test output")] -#![expect(clippy::unwrap_used, reason = "simplify test output")] use std::sync::Arc; use std::time::Duration; @@ -79,9 +78,16 @@ async fn github_error(world: &mut WorkerWorld) { #[when("the worker runs briefly")] 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; @@ -93,14 +99,28 @@ async fn worker_runs(world: &mut WorkerWorld) { #[then("the comment is posted")] 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")] 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 { From 709166b3d5eb216af5f06a9866af614ba00f62ca Mon Sep 17 00:00:00 2001 From: Leynos Date: Mon, 11 Aug 2025 19:38:48 +0100 Subject: [PATCH 3/3] Scope lint expectations in worker steps --- tests/steps/worker_steps.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/steps/worker_steps.rs b/tests/steps/worker_steps.rs index 212985b..6dbb247 100644 --- a/tests/steps/worker_steps.rs +++ b/tests/steps/worker_steps.rs @@ -2,8 +2,9 @@ //! //! These steps drive the Cucumber scenarios that verify the worker posts //! queued comments and handles failures gracefully. - -#![expect(clippy::expect_used, reason = "simplify test output")] +//! +//! 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; @@ -35,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); @@ -77,6 +82,10 @@ 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 @@ -98,6 +107,10 @@ 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().expect("server should be initialised"); assert!( @@ -110,6 +123,10 @@ async fn comment_posted(world: &mut WorkerWorld) { } #[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