Use TextDiffSubject to compare multi-line text (#406)

* Use TextDiffSubject to compare  multi-line text

It illustrates differences better.

Moved TextDiffSubject.java to the common project for sharing.
This commit is contained in:
Weimin Yu 2019-12-10 16:44:59 -05:00 committed by GitHub
parent f7b243e390
commit 3aad8b6aa7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 104 additions and 20 deletions

View file

@ -15,9 +15,9 @@
package google.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.truth.TextDiffSubject.assertThat;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.base.Charsets;
import com.google.common.io.Files;
import com.google.common.io.Resources;
import google.registry.persistence.NomulusPostgreSql;
@ -93,9 +93,7 @@ public class GenerateSqlSchemaCommandTest extends CommandTestCase<GenerateSqlSch
public void validateGeneratedSchemaIsSameAsSchemaInFile() throws Exception {
runCommand(
"--start_postgresql", "--out_file=" + tmp.getRoot() + File.separatorChar + "schema.sql");
assertThat(Files.readLines(new File(tmp.getRoot(), "schema.sql"), Charsets.UTF_8))
.isEqualTo(
Resources.readLines(
Resources.getResource("sql/schema/db-schema.sql.generated"), Charsets.UTF_8));
assertThat(new File(tmp.getRoot(), "schema.sql").toURI().toURL())
.hasSameContentAs(Resources.getResource("sql/schema/db-schema.sql.generated"));
}
}