mirror of
https://github.com/google/nomulus
synced 2026-02-11 15:21:28 +00:00
Start postgresql container in generate_sql_schema (#249)
* Start postgresql container in generate_sql_schema Add a --start-postgresql option to the nomulus generate_sql_schema command so that users don't have to start their own docker container to run it. * Made default behavior be to give guidance
This commit is contained in:
@@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import org.junit.Before;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
@@ -35,7 +36,7 @@ public class GenerateSqlSchemaCommandTest extends CommandTestCase<GenerateSqlSch
|
||||
|
||||
@Rule public TemporaryFolder tmp = new TemporaryFolder();
|
||||
|
||||
@Rule public PostgreSQLContainer postgres =
|
||||
@ClassRule public static PostgreSQLContainer postgres =
|
||||
new PostgreSQLContainer()
|
||||
.withDatabaseName("postgres")
|
||||
.withUsername("postgres")
|
||||
@@ -61,4 +62,22 @@ public class GenerateSqlSchemaCommandTest extends CommandTestCase<GenerateSqlSch
|
||||
// TODO: try running the schema against the test database.
|
||||
assertThat(new File(tmp.getRoot(), "schema.sql").exists()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncompatibleFlags() throws Exception {
|
||||
runCommand(
|
||||
"--out-file=" + tmp.getRoot() + File.separatorChar + "schema.sql",
|
||||
"--db-host=" + containerHostName,
|
||||
"--db-port=" + containerPort,
|
||||
"--start-postgresql");
|
||||
assertInStderr(GenerateSqlSchemaCommand.DB_OPTIONS_CLASH);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDockerPostgresql() throws Exception {
|
||||
runCommand(
|
||||
"--start-postgresql",
|
||||
"--out-file=" + tmp.getRoot() + File.separatorChar + "schema.sql");
|
||||
assertThat(new File(tmp.getRoot(), "schema.sql").exists()).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user