feat: Derive tests for derived schemas#571
Closed
Kriskras99 wants to merge 3 commits into
Closed
Conversation
Open
bb9dcde to
b004614
Compare
martin-g
reviewed
Jul 14, 2026
----- Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
b004614 to
0e982c4
Compare
martin-g
reviewed
Jul 14, 2026
| { | ||
| let ident = &self.ident; | ||
| self.add_test(Test { | ||
| name: "schema".to_string(), |
Member
There was a problem hiding this comment.
I don't get the idea of this PR :-/
It is invasive by generating tests no one asked for.
The end user will have to opt-out instead of opt-in for those tests.
It is not clear what is being tested too.
- The
nameis always"schema". Is it really needed ?! - The body always prints
"Invalid schema"to stderr should_panicis alwaysNone- The body just calls
get_schema(), so it tests runtime construction of the derived Schema and validates itsName. But one could assume that the users make use of the derived schema too in their application and tests, so this is kinda already covered.
Contributor
Author
There was a problem hiding this comment.
I think especially point 4 is a good point, so let's close this for now.
(1 and 3 are to allow generating other kinds of tests, 2 is so that the user gets some feedback when the test fails).
Contributor
Author
|
Closing for now, needs more work |
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.
This adds a test to every generated schema to check if the schema can actually be created. Tests are automatically disabled for types with generics, consts, or lifetimes. They can also be disabled by setting
#[avro(test = false)]on the type, for if a user uses a different validator at runtime or the type is inside a function which would trigger theunnameable_test_itemslint.In the future we could extend the attribute syntax to provide a different validator, so that use case would also be supported. I also think we should be able to test types with lifetimes, but that needs some further experimentation.