mock: add doctests for on_register_dispatch negative cases#3416
Merged
Conversation
In order to add a regression test, #3379 added support to `tracing-mock` to expect calls to `on_register_dispatch` for both mock subscribers and mock layers. A negative integration test for the layer case was included in #3415. However, there are no negative doctests for this (and as per my own suggestion, there's no negative test for the subscriber method either as I wasn't sure it was possible). After a bit of thought, I realised that we could include a negative test for the `MockSubscriber`. This change adds that test as a doctest, since we have those in almost all of our documentation and also includes the already written negative test for the `MockLayer` to a doctest.
jplatte
approved these changes
Nov 24, 2025
djc
approved these changes
Nov 24, 2025
davidbarsky
approved these changes
Nov 24, 2025
hds
added a commit
that referenced
this pull request
Nov 25, 2025
# 0.1.0-beta.2 (November 30, 2025) ### Added - Add `on_register_dispatch` expectation for subscriber and layer mocks ([#3415]) - Add doctests for `on_register_dispatch` negative cases ([#3416]) [#3415]: https://github.com/tokio-rs/tracing/pull/#3415 [#3416]: https://github.com/tokio-rs/tracing/pull/#3416
hds
added a commit
that referenced
this pull request
Nov 26, 2025
# 0.1.0-beta.2 (November 26, 2025) ### Added - Add `on_register_dispatch` expectation for subscriber and layer mocks ([#3415]) - Add doctests for `on_register_dispatch` negative cases ([#3416]) ### Changed - `tracing`: updated to 0.1.42 ([#3418]) [#3415]: https://github.com/tokio-rs/tracing/pull/#3415 [#3416]: https://github.com/tokio-rs/tracing/pull/#3416 [#3418]: https://github.com/tokio-rs/tracing/pull/#3418
hds
added a commit
that referenced
this pull request
Nov 26, 2025
# 0.1.0-beta.2 (November 26, 2025) ### Added - Add `on_register_dispatch` expectation for subscriber and layer mocks ([#3415]) - Add doctests for `on_register_dispatch` negative cases ([#3416]) ### Changed - `tracing`: updated to 0.1.42 ([#3418]) [#3415]: https://github.com/tokio-rs/tracing/pull/#3415 [#3416]: https://github.com/tokio-rs/tracing/pull/#3416 [#3418]: https://github.com/tokio-rs/tracing/pull/#3418
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.
Motivation
In order to add a regression test, #3379 added support to
tracing-mockto expect calls to
on_register_dispatchfor both mock subscribers andmock layers. A negative integration test for the layer case was included
in #3415. However, there are no negative doctests for this (and as per
my own suggestion, there's no negative test for the subscriber method
either as I wasn't sure it was possible).
Solution
After a bit of thought, I realised that we could include a negative test
for the
MockSubscriber. This change adds that test as a doctest, sincewe have those in almost all of our documentation and also includes the
already written negative test for the
MockLayerto a doctest.