Skip to content

test(channels): make the docs-target invariant's own failure paths covered - #785

Merged
huichen merged 1 commit into
mainfrom
test/chan-docs-invariant-coverage
Sep 22, 2026
Merged

huichen merged 1 commit into
mainfrom
test/chan-docs-invariant-coverage

Conversation

@huichen

@huichen huichen commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

test(channels): make the docs-target invariant's own failure paths covered

The invariant added in #784 carried four uncovered lines: its three assert!
messages and the panic! arm only materialise when the check fails, so a
passing suite never executes them. Worse, the negative controls that did
exercise them were throwaway edits — I confirmed the check works by breaking it
by hand and then put the file back, which leaves nothing behind that keeps
working.

Both problems have one fix: take the definitions as an argument and give each
failure mode a test that sees it fail.

  • docs_problem(root, docs) returns why a target leads nowhere, or None;
  • undocumented(definitions, root) collects them — parameterised, so a
    definition can be built per case;
  • a_docs_target_is_rejected_when_it_cannot_be_followed covers all four
    shapes: a resolvable path, a resolvable path with a valid anchor, a file that
    is not there, an anchor that is not there, and an empty value. The assertions
    name the channel in the message, which is what makes the failure actionable.

The three remaining uncovered lines were the multi-line assert! format
arguments, evaluated only on failure; hoisting each into a binding ahead of the
assert closes them.

an_anchor_is_the_slug_github_makes pins the slug rule directly, including the
two real cases that make it non-obvious (### \feishu`→feishu, ### iMessage (macOS)→imessage-macos`), so the anchor half of the check does
not depend on the page staying the way it is today.

providers/mod.rs is back to zero uncovered lines and the crate's total is
unchanged at 47 (22 framework, 25 in the older Feishu/DingTalk bridges and gRPC
client), which is the number docs/architecture/channels-test-coverage.md
records.

…vered

The invariant added in #784 carried four uncovered lines: its three `assert!`
messages and the `panic!` arm only materialise when the check fails, so a
passing suite never executes them. Worse, the negative controls that did
exercise them were throwaway edits — I confirmed the check works by breaking it
by hand and then put the file back, which leaves nothing behind that keeps
working.

Both problems have one fix: take the definitions as an argument and give each
failure mode a test that sees it fail.

* `docs_problem(root, docs)` returns why a target leads nowhere, or `None`;
* `undocumented(definitions, root)` collects them — parameterised, so a
  definition can be built per case;
* `a_docs_target_is_rejected_when_it_cannot_be_followed` covers all four
  shapes: a resolvable path, a resolvable path with a valid anchor, a file that
  is not there, an anchor that is not there, and an empty value. The assertions
  name the channel in the message, which is what makes the failure actionable.

The three remaining uncovered lines were the multi-line `assert!` format
arguments, evaluated only on failure; hoisting each into a binding ahead of the
assert closes them.

`an_anchor_is_the_slug_github_makes` pins the slug rule directly, including the
two real cases that make it non-obvious (`### \`feishu\`` → `feishu`,
`### iMessage (macOS)` → `imessage-macos`), so the anchor half of the check does
not depend on the page staying the way it is today.

`providers/mod.rs` is back to zero uncovered lines and the crate's total is
unchanged at 47 (22 framework, 25 in the older Feishu/DingTalk bridges and gRPC
client), which is the number `docs/architecture/channels-test-coverage.md`
records.
@huichen
huichen enabled auto-merge (squash) September 22, 2026 17:26
@huichen
huichen merged commit ab34d9b into main Sep 22, 2026
12 checks passed
@huichen
huichen deleted the test/chan-docs-invariant-coverage branch September 22, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant