use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.
the class DbRollbackCommandTest method testRollbackToDate.
@Test
public void testRollbackToDate() throws Exception {
// Migrate some DDL changes to the database
long migrationDate = System.currentTimeMillis();
migrateCommand.run(null, new Namespace(ImmutableMap.of()), conf);
// Rollback both changes (they're after the migration date)
rollbackCommand.run(null, new Namespace(ImmutableMap.of("date", new Date(migrationDate - 1000))), conf);
// Verify we can creat the table
dbi.useHandle(h -> h.execute("create table persons(id int, name varchar(255))"));
}
use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.
the class DbRollbackCommandTest method testRollbackToTag.
@Test
public void testRollbackToTag() throws Exception {
// Migrate the first DDL change to the database
migrateCommand.run(null, new Namespace(ImmutableMap.of("count", 1)), conf);
// Tag it
final DbTagCommand<TestMigrationConfiguration> tagCommand = new DbTagCommand<>(new TestMigrationDatabaseConfiguration(), TestMigrationConfiguration.class, migrationsFileName);
tagCommand.run(null, new Namespace(ImmutableMap.of("tag-name", ImmutableList.of("v1"))), conf);
// Migrate the second change
migrateCommand.run(null, new Namespace(ImmutableMap.of()), conf);
// Rollback to the first change
rollbackCommand.run(null, new Namespace(ImmutableMap.of("tag", "v1")), conf);
// Verify we can add the second change manually
dbi.useHandle(h -> h.execute("alter table persons add column email varchar(128)"));
}
use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.
the class DbStatusCommandTest method testRun.
@Test
public void testRun() throws Exception {
statusCommand.run(null, new Namespace(ImmutableMap.of()), conf);
assertThat(baos.toString(UTF_8)).matches("3 change sets have not been applied to \\S+" + System.lineSeparator());
}
use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.
the class DbStatusCommandTest method testRunOnMigratedDb.
@Test
public void testRunOnMigratedDb() throws Exception {
final String existedDbPath = new File(Resources.getResource("test-db.mv.db").toURI()).getAbsolutePath();
final String existedDbUrl = "jdbc:h2:" + StringUtils.removeEnd(existedDbPath, ".mv.db");
final TestMigrationConfiguration existedDbConf = createConfiguration(existedDbUrl);
statusCommand.run(null, new Namespace(ImmutableMap.of()), existedDbConf);
assertThat(baos.toString(UTF_8)).matches("\\S+ is up to date" + System.lineSeparator());
}
use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.
the class DbStatusCommandTest method testVerbose.
@Test
public void testVerbose() throws Exception {
statusCommand.run(null, new Namespace(ImmutableMap.of("verbose", (Object) true)), conf);
assertThat(baos.toString(UTF_8)).matches("3 change sets have not been applied to \\S+" + System.lineSeparator() + "\\s*migrations\\.xml::1::db_dev" + System.lineSeparator() + "\\s*migrations\\.xml::2::db_dev" + System.lineSeparator() + "\\s*migrations\\.xml::3::db_dev" + System.lineSeparator());
}
Aggregations