Skip to content

Commit

Permalink
Make ignoreLinesStartingWith varargs (#2691)
Browse files Browse the repository at this point in the history
It still is a list, because we String::startsWith does not benefit from
the target being in a set.
  • Loading branch information
jianglai authored Feb 26, 2025
1 parent 0f3b62d commit 9fe64bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
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;
Expand Down Expand Up @@ -64,7 +63,7 @@ public class TextDiffSubject extends Subject {

private final ImmutableList<String> actual;
private DiffFormat diffFormat = DiffFormat.SIDE_BY_SIDE_MARKDOWN;
private List<String> comments = new ArrayList<>();
private ImmutableList<String> comments = ImmutableList.of();

protected TextDiffSubject(FailureMetadata metadata, List<String> actual) {
super(metadata, actual);
Expand All @@ -86,8 +85,8 @@ public TextDiffSubject withDiffFormat(DiffFormat format) {
}

/** 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void deploySchema_emptyDb() throws Exception {
Joiner.on(File.separatorChar).join(MOUNTED_RESOURCE_PATH, DUMP_OUTPUT_FILE));

assertThat(dumpedSchema)
.ignoringLinesThatStartWith("--")
.ignoringLinesStartingWith("--")
.hasSameContentAs(Resources.getResource("sql/schema/nomulus.golden.sql"));
}

Expand Down

0 comments on commit 9fe64bf

Please sign in to comment.