Repository navigation
test(channels): close the framework's uncovered lines and record the rest - #781
Merged
Merged
Conversation
…rest Per-line coverage (llvm-cov `DA:<line>,0`) of the channel framework, on top of the twelve providers. Two arms turned out to be dead by construction and were deleted rather than exempted, one guard was made testable, and five tests close behaviours that were previously only exercised by accident. Removed: - `slack::parse_event` and `mattermost::parse_posted` returned `Result<Option<Inbound>>` while having no error path at all, so every caller carried an unreachable `Err` arm. They return `Option<Inbound>` now, and clippy's `question_mark` hint folded a `let ... else` into `?`. - `evict_idle` had a `None => return` that the capacity guard above it makes impossible (the guard leaves at least one conversation other than `keep`), and its tail read as an unbounded loop with a second exit. It is now a `while` bounded by the table size, with the invariant stated where it is relied on. Made testable: - `start_all` decides each registered channel in `entry_action`, which takes a definition instead of reaching into the registry. That is what lets "enabled but not built is reported, not silently skipped" be covered: no planned channel ships in this build, so the test constructs one. New tests: - an unreadable channel config no longer hides a prompt: the attachment fetch fails, the message is still handed to the bridge and acknowledged; - the Events API webhook test now *waits for the dispatched event's acknowledgement* instead of sleeping 300ms and asserting nothing — the previous assertion claimed a denied event, but the message was in fact dropped as backpressure and never reached the pipeline; - a supervisor loop with a wedged data directory reports the provider failure and still stops cleanly when asked (the existing test never polled the task, which is why the warning was uncovered); - a read error ends `pump_lines` instead of retrying it. Also verified by experiment (and recorded): a server that drops a websocket without a close frame does not end the stream — the client reports `ResetWithoutClosingHandshake` on the read arm — so the `None` arm of both session loops cannot be reached through this client. `docs/architecture/channels-test-coverage.md` (+ zh-CN) states the rule and lists the 22 lines that remain uncovered, grouped as environmental, unreachable-by-construction, or attribution artifact, each with the reason or the test that proves the code runs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test(channels): close the framework's uncovered lines and record the rest
Per-line coverage (llvm-cov
DA:<line>,0) of the channel framework, on top ofthe twelve providers. Two arms turned out to be dead by construction and were
deleted rather than exempted, one guard was made testable, and five tests close
behaviours that were previously only exercised by accident.
Removed:
slack::parse_eventandmattermost::parse_postedreturnedResult<Option<Inbound>>while having no error path at all, so every callercarried an unreachable
Errarm. They returnOption<Inbound>now, andclippy's
question_markhint folded alet ... elseinto?.evict_idlehad aNone => returnthat the capacity guard above it makesimpossible (the guard leaves at least one conversation other than
keep), andits tail read as an unbounded loop with a second exit. It is now a
whilebounded by the table size, with the invariant stated where it is relied on.
Made testable:
start_alldecides each registered channel inentry_action, which takes adefinition instead of reaching into the registry. That is what lets
"enabled but not built is reported, not silently skipped" be covered: no
planned channel ships in this build, so the test constructs one.
New tests:
fails, the message is still handed to the bridge and acknowledged;
acknowledgement instead of sleeping 300ms and asserting nothing — the
previous assertion claimed a denied event, but the message was in fact
dropped as backpressure and never reached the pipeline;
and still stops cleanly when asked (the existing test never polled the task,
which is why the warning was uncovered);
pump_linesinstead of retrying it.Also verified by experiment (and recorded): a server that drops a websocket
without a close frame does not end the stream — the client reports
ResetWithoutClosingHandshakeon the read arm — so theNonearm of bothsession loops cannot be reached through this client.
docs/architecture/channels-test-coverage.md(+ zh-CN) states the rule andlists the 22 lines that remain uncovered, grouped as environmental,
unreachable-by-construction, or attribution artifact, each with the reason or
the test that proves the code runs.