From 9fe64bf9ec3dc458c6468282d7c87fbca7571698 Mon Sep 17 00:00:00 2001 From: Lai Jiang Date: Wed, 26 Feb 2025 12:12:24 -0500 Subject: [PATCH] Make ignoreLinesStartingWith varargs (#2691) It still is a list, because we String::startsWith does not benefit from the target being in a set. --- .../google/registry/testing/truth/TextDiffSubject.java | 7 +++---- .../test/java/google/registry/sql/flyway/SchemaTest.java | 2 +- 2 files changed, 4 insertions(+), 5 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 894c92ff3..80bf5e187 100644 --- a/common/src/testing/java/google/registry/testing/truth/TextDiffSubject.java +++ b/common/src/testing/java/google/registry/testing/truth/TextDiffSubject.java @@ -35,7 +35,6 @@ import com.google.common.truth.SimpleSubjectBuilder; import com.google.common.truth.Subject; import java.io.IOException; import java.net.URL; -import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.List; @@ -64,7 +63,7 @@ public class TextDiffSubject extends Subject { private final ImmutableList actual; private DiffFormat diffFormat = DiffFormat.SIDE_BY_SIDE_MARKDOWN; - private List comments = new ArrayList<>(); + private ImmutableList comments = ImmutableList.of(); protected TextDiffSubject(FailureMetadata metadata, List actual) { super(metadata, actual); @@ -86,8 +85,8 @@ public class TextDiffSubject extends Subject { } /** If set, ignore lines that start with the given string. */ - public TextDiffSubject ignoringLinesThatStartWith(String comment) { - comments.add(comment); + public TextDiffSubject ignoringLinesStartingWith(String... comments) { + this.comments = ImmutableList.copyOf(comments); return this; } 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 5a8bb133c..ce810b0f6 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) - .ignoringLinesThatStartWith("--") + .ignoringLinesStartingWith("--") .hasSameContentAs(Resources.getResource("sql/schema/nomulus.golden.sql")); }