test(channels): add injectable test transport to TelegramChannel#2128
Merged
test(channels): add injectable test transport to TelegramChannel#2128
Conversation
Add new_test() constructor under #[cfg(test)] that injects the mpsc::Sender<IncomingMessage> directly, enabling unit tests without a real Telegram bot token or live API access. Add 12 behavioural tests covering: - recv() message delivery, /reset and /skills routing, unknown-command passthrough, channel-close returning None - send_chunk() text accumulation (throttle prevents API call) - flush_chunks() state clearing with and without message_id (wiremock for edit path) - /start consumed internally via wiremock - confirm() timeout, channel-close, yes, and non-yes logic at the rx-timeout level Add wiremock and tokio test-util to zeph-channels dev-dependencies. No production code paths were changed. Closes #2121
…channels-injectable
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.
Summary
new_test()constructor under#[cfg(test)]that returns(TelegramChannel, mpsc::Sender<IncomingMessage>), enabling unit tests without a real bot token or live Telegram APImake_mocked_channel()test helper using wiremock to intercept bot API calls for paths that callsend()(the/startwelcome message andflush_chunks()withmessage_id)Test coverage added
recv()returns message on injectnew_test()/resetand/skillsrouted correctlynew_test()new_test()Nonenew_test()send_chunk()accumulates without APInew_test()+ setlast_editflush_chunks()clears state (nomessage_id)new_test()/startconsumed internallyflush_chunks()withmessage_idconfirm()timeout logicconfirm()channel-close logicconfirm()accepts "yes"confirm()rejects non-"yes"Test plan
cargo nextest run -p zeph-channels— 99 tests passed, 0 skippedcargo +nightly fmt --check— cleancargo clippy --workspace --features full -- -D warnings— cleanCloses #2121