mirror of
https://github.com/google/nomulus.git
synced 2025-07-09 20:53:26 +02:00
Add a generate_sql_schema command (#230)
* Add a generate_schema command
Add a generate_schema command to nomulus tool and add the necessary
instrumentation to EppResource and DomainBase to allow us to generate a
proof-of-concept schema for DomainBase.
* Added forgotten command description
* Revert "Added forgotten command description"
This reverts commit 09326cb8ac
.
(checked in the wrong file)
* Added fixes requested during review
* Add a todo to start postgresql container
Add a todo to start a postgresql container from generate_sql_command.
This commit is contained in:
parent
3ba6e7bd06
commit
6dee3d526e
8 changed files with 183 additions and 17 deletions
|
@ -0,0 +1,64 @@
|
|||
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
package google.registry.tools;
|
||||
|
||||
// import static org.mockito.Mockito.mock;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.testcontainers.containers.PostgreSQLContainer;
|
||||
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public class GenerateSqlSchemaCommandTest extends CommandTestCase<GenerateSqlSchemaCommand> {
|
||||
|
||||
private String containerHostName;
|
||||
private int containerPort;
|
||||
|
||||
@Rule public TemporaryFolder tmp = new TemporaryFolder();
|
||||
|
||||
@Rule public PostgreSQLContainer postgres =
|
||||
new PostgreSQLContainer()
|
||||
.withDatabaseName("postgres")
|
||||
.withUsername("postgres")
|
||||
.withPassword("domain-registry");
|
||||
|
||||
public GenerateSqlSchemaCommandTest() {}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
containerHostName = postgres.getContainerIpAddress();
|
||||
containerPort = postgres.getMappedPort(GenerateSqlSchemaCommand.POSTGRESQL_PORT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSchemaGeneration() throws Exception {
|
||||
runCommand(
|
||||
"--out-file=" + tmp.getRoot() + File.separatorChar + "schema.sql",
|
||||
"--db-host=" + containerHostName,
|
||||
"--db-port=" + containerPort);
|
||||
|
||||
// We're just interested in verifying that there is a schema file generated, we don't do any
|
||||
// checks on the contents, this would make the test too brittle and serves no real purpose.
|
||||
// TODO: try running the schema against the test database.
|
||||
assertThat(new File(tmp.getRoot(), "schema.sql").exists()).isTrue();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue