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));
}
}

View file

@ -44,9 +44,9 @@
repo_id text not null,
creation_client_id text,
current_sponsor_client_id text,
deletion_time bytea,
deletion_time timestamptz,
last_epp_update_client_id text,
last_epp_update_time bytea,
last_epp_update_time timestamptz,
revisions bytea,
auth_info_repo_id text,
auth_info_value text,
@ -55,12 +55,12 @@
delete_poll_message bytea,
fully_qualified_domain_name text,
idn_table_name text,
last_transfer_time bytea,
launch_notice_accepted_time bytea,
launch_notice_expiration_time bytea,
last_transfer_time timestamptz,
launch_notice_accepted_time timestamptz,
launch_notice_expiration_time timestamptz,
launch_notice_tcn_id text,
launch_notice_validator_id text,
registration_expiration_time bytea,
registration_expiration_time timestamptz,
smd_id text,
tld text,
transfer_data_server_approve_autorenrew_event bytea,
@ -70,11 +70,11 @@
value int4,
client_transaction_id text,
server_transaction_id text,
transfer_data_registration_expiration_time bytea,
transfer_data_registration_expiration_time timestamptz,
gaining_client_id text,
losing_client_id text,
pending_transfer_expiration_time bytea,
transfer_request_time bytea,
pending_transfer_expiration_time timestamptz,
transfer_request_time timestamptz,
transfer_status int4,
primary key (repo_id)
);
@ -117,7 +117,7 @@
billing_event_one_time bytea,
billing_event_recurring bytea,
client_id text,
expiration_time bytea,
expiration_time timestamptz,
type int4,
primary key (id)
);