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

Make it possible to ignore comment lines when comparing schemas #2690

Merged
merged 1 commit into from
Feb 25, 2025

Conversation

jianglai
Copy link
Collaborator

@jianglai jianglai commented Feb 25, 2025

We now pin to postgreSQL v17 when running tests, which means that minor
version might increase without our intervention. This causes (at least)
the comment in the golden schema to change, and failing the test as a
result.

This PR adds the ability to strip lines that we deem as comment from the
comparison, so we don't have to do trivial upgrades to the gold schema
whenever there's minor version upgrade.


This change is Reviewable

We now pin to postgreSQL v17 when running tests, which means that minor
version might increase without our intervention. This causes (at least)
the comment in the golden schema to change, and failing the test as a
result.

This PR adds the ability to strip lines that we deem as comment from the
comparison, so we don't have to do trivial upgrades to the gold schema
whenever there's minor version upgrade.
@jianglai jianglai requested a review from gbrodman February 25, 2025 14:53
@jianglai jianglai enabled auto-merge February 25, 2025 14:53
Copy link
Collaborator

@gbrodman gbrodman left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @jianglai)

@jianglai jianglai added this pull request to the merge queue Feb 25, 2025
Merged via the queue into google:master with commit fb816d7 Feb 25, 2025
9 checks passed
@jianglai jianglai deleted the schema-comment branch February 25, 2025 17:52
Copy link
Member

@CydeWeys CydeWeys left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions


common/src/testing/java/google/registry/testing/truth/TextDiffSubject.java line 89 at r1 (raw file):

  /** If set, ignore lines that start with the given string. */
  public TextDiffSubject ignoringLinesThatStartWith(String comment) {

I think it's cleaner if the method signature here is a varargs, and then comments can be of type ImmutableSet<String>. It'll be nicer from callsites as well, e.g. compare:

assertThat(...).ignoringLinesStartingWith("--", "//", "#").isEqualTo(...);
assertThat(...).ignoringLinesStartingWith("--").ignoringLinesStartingWith("//").ignoringLinesStartingWith("#").isEqualTo(...);

common/src/testing/java/google/registry/testing/truth/TextDiffSubject.java line 89 at r1 (raw file):

  /** If set, ignore lines that start with the given string. */
  public TextDiffSubject ignoringLinesThatStartWith(String comment) {

It's minor but I think ignoringLinesStartingWith() might be a slightly better name.

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.

3 participants