Skip to content

fix(channels): test the telegram webhook defaults without assuming a free port - #779

Merged
huichen merged 1 commit into
mainfrom
fix/chan-telegram-webhook-cov
Sep 22, 2026
Merged

huichen merged 1 commit into
mainfrom
fix/chan-telegram-webhook-cov

Conversation

@huichen

@huichen huichen commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

What and why

channels/src/providers/telegram.rs had one uncovered line on main (line 939, the default webhook address). The cause is a regression from my own CI fix in #778:

  • the original test asserted the default 127.0.0.1:8787 was unavailable because a local service held it on the machine it was written on — on a clean machine the bind succeeds and the run loop never returns, which is how it failed CI;
  • my fix made the test bind its own port, so it now always passes an explicit address and the default branch has no test.

The change

Address and path selection move out of the run loop into webhook_addr / webhook_path, so both branches are asserted directly rather than through a bind attempt:

Config webhook_addr webhook_path
no webhook block 127.0.0.1:8787 /telegram
explicit addr + path the configured values the configured value
block with only secret_token default default

No test depends on a port being free or taken, so it behaves the same on a laptop and on a CI runner.

Verification

cargo test -p future-channel --lib providers::telegram     # 69 passed
cargo fmt -p future-channel --check                        # clean
cargo clippy -p future-channel --all-targets -- -D warnings # clean (pinned 1.97)
bash scripts/chan-cov.sh --check channels/src/providers/telegram.rs
  ok   channels/src/providers/telegram.rs: 0 uncovered lines

This is the first item of the residual-coverage list in #778 (comment); the rest (slack 11, mattermost 5, imessage 2, qq 1, plus the documented exemptions) is unchanged.

… a free port

The default address and path for the Telegram webhook were covered only by a test
that expected the default port to be taken. That assumption held on the machine
it was written on and failed in CI, so the test now supplies its own address —
which left the default branch unexercised.

Address and path selection move into `webhook_addr` / `webhook_path`, and a test
asserts both branches directly: a config without a webhook block keeps the
defaults, an explicit block wins, and a partial block keeps whichever half it
does not name. No test depends on the default port being free or taken.

Verified: `cargo test -p future-channel --lib providers::telegram` (69 passed),
`cargo fmt --check` and `clippy --all-targets -- -D warnings` on the pinned
toolchain, and `bash scripts/chan-cov.sh --check channels/src/providers/telegram.rs`
reporting 0 uncovered lines.
@huichen
huichen enabled auto-merge (squash) September 22, 2026 14:57
@huichen
huichen merged commit 976b174 into main Sep 22, 2026
12 checks passed
@huichen
huichen deleted the fix/chan-telegram-webhook-cov branch September 22, 2026 15:02
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