Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: Removes Explicit Parameterization of Schema Tests #11444

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

RussellSpitzer
Copy link
Member

@RussellSpitzer RussellSpitzer commented Nov 1, 2024

A lot of our tests are currently very specific but are going to be reused for various other types as they get added. We also currently hard code in the versions we are testing. This makes it a little more difficult whenever we add a new format version to correctly update all of the corresponding tests.

I'm updating TestSchema to show what I think should be our general pattern for version specific testing where the versions tested are defined in a single location rather than each time per test.

For the "type" tests, rather than making a named test per type, we parameterize over the type itself so that new types (Geo and Variant) can be added without duplicating code.

@github-actions github-actions bot added the API label Nov 1, 2024
private static final Map<Type.TypeID, Integer> MIN_FORMAT_VERSIONS =
ImmutableMap.of(Type.TypeID.TIMESTAMP_NANO, 3);

private static final Integer MIN_FORMAT_INITIAL_DEFAULT = 3;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think maybe I should just be extracting these from Schema rather than redeclaring them here ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only worry here is we won't catch bugs in bad constants in Schema.java, probably not a real worry


private static final Integer MIN_FORMAT_INITIAL_DEFAULT = 3;

private static final Integer MAX_FORMAT_VERSION = 3;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a test constant i'd really like to have in just one file somewhere in API, placed here now to demonstrate what I want to do

@RussellSpitzer
Copy link
Member Author

Test results look like
image

Copy link
Contributor

@aihuaxu aihuaxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for refactoring the tests. LGTM. That avoids the duplication.

private static final Map<Type.TypeID, Integer> MIN_FORMAT_VERSIONS =
ImmutableMap.of(Type.TypeID.TIMESTAMP_NANO, 3);

private static final Integer MIN_FORMAT_INITIAL_DEFAULT = 3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1.

Copy link
Contributor

@Fokko Fokko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, thanks @RussellSpitzer

@Fokko Fokko requested a review from nastra November 5, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants