2.2 KiB
2.2 KiB
099 — Remove test_handle's duplicate-of-spawn test stub
Summary
test_handle is a #[cfg(test)] production-file function that exists
only to give tests access to the engine's internal mpsc::Receiver —
it duplicates spawn() almost line-for-line rather than exposing that
receiver through spawn()/EngineHandle itself. Per this repo's
IDEAS.md guidance: prefer changing a function's scope/visibility (or
the tests) over maintaining a parallel stub.
Where
src/engine/handle.rs:113-128—#[cfg(test)] pub(crate) fn test_handle(channel_capacity: usize) -> (EngineHandle, mpsc::Receiver<EngineMessage>), duplicatingspawn()(src/engine/handle.rs:103-111) except thatspawn()discards the receiver after wiring the actor loop, whiletest_handlereturns it raw.- Re-exported at
src/engine/mod.rs:21:pub(crate) use handle::test_handle;. - Consumed only by tests in
src/engine/ingest.rs:228(use crate::engine::test_handle;) and called at lines 248, 264, 281, 302 inside#[cfg(test)] mod tests.
Scope
- Remove
test_handleand instead give tests access viaspawn()itself — e.g. havespawn()take an optional channel-capacity override and always hand back the receiver alongside the handle (or the actor join handle), with production call sites (main.rs) simply ignoring what they don't need, rather than keeping a second constructor whose only difference is what it returns. - Update the four call sites in
src/engine/ingest.rs's test module to use the adjustedspawn()signature. - Out of scope: the other test-fixture helpers in
src/engine/tests.rs(metric_request,declare_test_param,ingest_log,logs_query,logs_query_sorted, etc.) are ordinary test-data builders, not visibility workarounds — leave those alone. Also leave the#[allow(dead_code)]items (src/engine/message.rs:11,29,src/api/mcp_server.rs:254,src/config/mod.rs:27, and similar inmetric_primitive.rs/data_value.rs/timestamp.rs/index_key.rs) untouched — they weren't confirmed to be test-visibility stubs and need individual inspection before deciding whether they're even related to this ticket's pattern.