mirror of
https://github.com/google/nomulus.git
synced 2025-07-09 12:43:24 +02: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:
parent
dc9d9158d8
commit
d3ccad3aa7
3 changed files with 102 additions and 24 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue