From 1164070576855c1be3e18deb13604648cc7457e8 Mon Sep 17 00:00:00 2001 From: Weimin Yu Date: Mon, 18 Aug 2025 20:41:47 +0000 Subject: [PATCH] Update golden schema comparison in schema test (#2805) Postgresql-17.6 introduces two new lines in pg_dump output as a security feature: `\restricted {HASH}` and `\unrestricted {HASH}`. We filter out lines starting with these two prefixes when comparing schemas. The db upgrade also adds two empty lines to the pg_dump output. We know ignore all empty lines when comparing schemas. --- .../google/registry/testing/truth/TextDiffSubject.java | 8 +++++--- .../test/java/google/registry/sql/flyway/SchemaTest.java | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/common/src/testing/java/google/registry/testing/truth/TextDiffSubject.java b/common/src/testing/java/google/registry/testing/truth/TextDiffSubject.java index 80bf5e187..a30c0658a 100644 --- a/common/src/testing/java/google/registry/testing/truth/TextDiffSubject.java +++ b/common/src/testing/java/google/registry/testing/truth/TextDiffSubject.java @@ -92,17 +92,19 @@ public class TextDiffSubject extends Subject { private ImmutableList filterComments(List lines) { return lines.stream() + .filter(line -> !line.isBlank()) .filter(line -> comments.stream().noneMatch(line::startsWith)) .collect(ImmutableList.toImmutableList()); } public void hasSameContentAs(List expectedContent) { checkNotNull(expectedContent, "expectedContent"); - ImmutableList expected = filterComments(expectedContent); - if (filterComments(expected).equals(filterComments(actual))) { + ImmutableList filteredExpected = filterComments(expectedContent); + ImmutableList filteredActual = filterComments(actual); + if (filteredExpected.equals(filteredActual)) { return; } - String diffString = diffFormat.generateDiff(expected, actual); + String diffString = diffFormat.generateDiff(filteredExpected, filteredActual); failWithoutActual( Fact.simpleFact( Joiner.on('\n') diff --git a/db/src/test/java/google/registry/sql/flyway/SchemaTest.java b/db/src/test/java/google/registry/sql/flyway/SchemaTest.java index ce810b0f6..90ac0b8ce 100644 --- a/db/src/test/java/google/registry/sql/flyway/SchemaTest.java +++ b/db/src/test/java/google/registry/sql/flyway/SchemaTest.java @@ -115,7 +115,7 @@ class SchemaTest { Joiner.on(File.separatorChar).join(MOUNTED_RESOURCE_PATH, DUMP_OUTPUT_FILE)); assertThat(dumpedSchema) - .ignoringLinesStartingWith("--") + .ignoringLinesStartingWith("--", "\\restrict", "\\unrestrict") .hasSameContentAs(Resources.getResource("sql/schema/nomulus.golden.sql")); }