From 9c42d375b26c43a82d28072ac2189222303d5ac0 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Thu, 2 Apr 2026 14:25:06 -0700 Subject: [PATCH] Clean up server integration tests Remove empty server.rs, redundant comments, redundant server.json existence check (already covered by status check), unnecessary String allocation, and unnecessary final filters.clone(). Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/crates/fabro-cli/tests/it/cmd/mod.rs | 1 - lib/crates/fabro-cli/tests/it/cmd/server.rs | 1 - .../fabro-cli/tests/it/cmd/server_start.rs | 3 --- .../tests/it/scenario/server_lifecycle.rs | 19 ++++--------------- 4 files changed, 4 insertions(+), 20 deletions(-) delete mode 100644 lib/crates/fabro-cli/tests/it/cmd/server.rs diff --git a/lib/crates/fabro-cli/tests/it/cmd/mod.rs b/lib/crates/fabro-cli/tests/it/cmd/mod.rs index 0cf72823c..5a517c6e6 100644 --- a/lib/crates/fabro-cli/tests/it/cmd/mod.rs +++ b/lib/crates/fabro-cli/tests/it/cmd/mod.rs @@ -51,7 +51,6 @@ mod secret_rm; mod secret_set; mod send_analytics; mod send_panic; -mod server; mod server_start; mod server_status; mod server_stop; diff --git a/lib/crates/fabro-cli/tests/it/cmd/server.rs b/lib/crates/fabro-cli/tests/it/cmd/server.rs deleted file mode 100644 index 8b1378917..000000000 --- a/lib/crates/fabro-cli/tests/it/cmd/server.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/lib/crates/fabro-cli/tests/it/cmd/server_start.rs b/lib/crates/fabro-cli/tests/it/cmd/server_start.rs index 15bfbc24f..b28cc2c6d 100644 --- a/lib/crates/fabro-cli/tests/it/cmd/server_start.rs +++ b/lib/crates/fabro-cli/tests/it/cmd/server_start.rs @@ -60,14 +60,12 @@ fn start_already_running_exits_with_error() { let bind_addr = sock_dir.path().join("test.sock"); let bind_str = bind_addr.to_string_lossy().to_string(); - // Start the daemon context .command() .args(["server", "start", "--dry-run", "--bind", &bind_str]) .assert() .success(); - // Try to start again -- should fail with "already running" let mut filters = context.filters(); filters.push((r"pid \d+".to_string(), "pid [PID]".to_string())); filters.push((regex::escape(&bind_str), "[SOCKET_PATH]".to_string())); @@ -81,7 +79,6 @@ fn start_already_running_exits_with_error() { error: Server already running (pid [PID]) on [SOCKET_PATH] "); - // Clean up: stop the server context .command() .args(["server", "stop"]) diff --git a/lib/crates/fabro-cli/tests/it/scenario/server_lifecycle.rs b/lib/crates/fabro-cli/tests/it/scenario/server_lifecycle.rs index e2a262fc8..314a733fc 100644 --- a/lib/crates/fabro-cli/tests/it/scenario/server_lifecycle.rs +++ b/lib/crates/fabro-cli/tests/it/scenario/server_lifecycle.rs @@ -17,7 +17,6 @@ fn start_status_stop_lifecycle() { "started [UPTIME] ago".to_string(), )); - // Start the server as a daemon with a Unix socket in a short path let mut cmd = context.command(); cmd.args(["server", "start", "--dry-run", "--bind", &bind_str]); fabro_snapshot!(filters.clone(), cmd, @" @@ -28,13 +27,6 @@ fn start_status_stop_lifecycle() { Server started (pid [PID]) on [SOCKET_PATH] "); - // Verify server.json is written in storage_dir - assert!( - context.storage_dir.join("server.json").exists(), - "server.json should exist after start" - ); - - // Status should report running let mut cmd = context.command(); cmd.args(["server", "status"]); fabro_snapshot!(filters.clone(), cmd, @" @@ -45,22 +37,21 @@ fn start_status_stop_lifecycle() { Server running (pid [PID]) on [SOCKET_PATH], started [UPTIME] ago "); - // Status --json should produce valid JSON with "running" status let status_output = context .command() .args(["server", "status", "--json"]) .assert() .success(); - let stdout = String::from_utf8(status_output.get_output().stdout.clone()).unwrap(); + let stdout = std::str::from_utf8(&status_output.get_output().stdout) + .expect("status --json stdout should be valid UTF-8"); let json: serde_json::Value = - serde_json::from_str(&stdout).expect("status --json should be valid JSON"); + serde_json::from_str(stdout).expect("status --json should be valid JSON"); assert_eq!( json["status"].as_str(), Some("running"), "status should be running" ); - // Stop the server let mut cmd = context.command(); cmd.args(["server", "stop"]); fabro_snapshot!(filters.clone(), cmd, @" @@ -71,10 +62,9 @@ fn start_status_stop_lifecycle() { Server stopped "); - // Status should report not running let mut cmd = context.command(); cmd.args(["server", "status"]); - fabro_snapshot!(filters.clone(), cmd, @" + fabro_snapshot!(filters, cmd, @" success: false exit_code: 1 ----- stdout ----- @@ -82,7 +72,6 @@ fn start_status_stop_lifecycle() { Server is not running "); - // Verify server.json is cleaned up assert!( !context.storage_dir.join("server.json").exists(), "server.json should be removed after stop"