Add a test to verify generated schema (#377)

This commit is contained in:
Shicong Huang 2019-11-21 13:37:37 -05:00 committed by GitHub
parent 6af1896362
commit 98414cb7cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 10 deletions

View file

@ -17,7 +17,9 @@ package google.registry.tools;
import static com.google.common.truth.Truth.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;
import java.io.File;
import org.junit.Before;
@ -86,4 +88,14 @@ public class GenerateSqlSchemaCommandTest extends CommandTestCase<GenerateSqlSch
"--start_postgresql", "--out_file=" + tmp.getRoot() + File.separatorChar + "schema.sql");
assertThat(new File(tmp.getRoot(), "schema.sql").exists()).isTrue();
}
@Test
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));
}
}