From d290ac8528a04d225c59b2a92417ea101efca746 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 13:05:49 +0000 Subject: [PATCH] refactor(test): clean up CLI test helpers and improve code clarity Co-authored-by: jnsgruk <668505+jnsgruk@users.noreply.github.com> --- tests/cli/helpers.rs | 17 +++++++---------- tests/cli/roasters_cli.rs | 4 ++-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/tests/cli/helpers.rs b/tests/cli/helpers.rs index a7ce721..0349ba5 100644 --- a/tests/cli/helpers.rs +++ b/tests/cli/helpers.rs @@ -4,16 +4,13 @@ use std::sync::Mutex; use std::time::Duration; use tempfile::TempDir; -/// Shared test server state +/// Shared test server state - kept alive for the duration of all tests struct SharedServer { address: String, admin_password: String, - #[allow(dead_code)] - db_url: String, - #[allow(dead_code)] - temp_dir: TempDir, - #[allow(dead_code)] - process: std::process::Child, + _db_url: String, + _temp_dir: TempDir, + _process: std::process::Child, } /// Single shared test server for all CLI tests @@ -106,9 +103,9 @@ fn ensure_server_started() -> Result<(String, String), String> { *server = Some(SharedServer { address: address.clone(), admin_password: admin_password.to_string(), - db_url, - temp_dir, - process, + _db_url: db_url, + _temp_dir: temp_dir, + _process: process, }); } diff --git a/tests/cli/roasters_cli.rs b/tests/cli/roasters_cli.rs index a1881c3..167136f 100644 --- a/tests/cli/roasters_cli.rs +++ b/tests/cli/roasters_cli.rs @@ -32,8 +32,8 @@ fn test_add_roaster_with_authentication() { ); let stdout = String::from_utf8_lossy(&output.stdout); - let roaster: Value = - serde_json::from_str(&stdout).expect(&format!("Should output valid JSON, got: {}", stdout)); + let roaster: Value = serde_json::from_str(&stdout) + .unwrap_or_else(|_| panic!("Should output valid JSON, got: {}", stdout)); assert_eq!(roaster["name"], "Test Roasters"); assert_eq!(roaster["country"], "UK");