use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.
the class DbRollbackCommandTest method testRollbackToDateAsDryRun.
@Test
public void testRollbackToDateAsDryRun() throws Exception {
// Migrate some DDL changes to the database
long migrationDate = System.currentTimeMillis();
migrateCommand.run(null, new Namespace(ImmutableMap.of()), conf);
// Print out a rollback script for both changes after the migration date
rollbackCommand.setOutputStream(new PrintStream(baos, true));
rollbackCommand.run(null, new Namespace(ImmutableMap.of("date", new Date(migrationDate - 1000), "dry-run", true)), conf);
assertThat(baos.toString(UTF_8)).containsIgnoringCase("ALTER TABLE PUBLIC.persons DROP COLUMN email;").containsIgnoringCase("DROP TABLE PUBLIC.persons;");
}
use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.
the class DbRollbackCommandTest method testRollbackNChanges.
@Test
public void testRollbackNChanges() throws Exception {
// Migrate some DDL changes to the database
migrateCommand.run(null, new Namespace(ImmutableMap.of()), conf);
// Rollback the last one (the email field)
rollbackCommand.run(null, new Namespace(ImmutableMap.of("count", 1)), conf);
// Now we can add it
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 DbRollbackCommandTest method testRollbackToTagAsDryRun.
@Test
public void testRollbackToTagAsDryRun() 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);
// Print out the rollback script for the second change
rollbackCommand.setOutputStream(new PrintStream(baos, true));
rollbackCommand.run(null, new Namespace(ImmutableMap.of("tag", "v1", "dry-run", true)), conf);
assertThat(baos.toString(UTF_8)).containsIgnoringCase("ALTER TABLE PUBLIC.persons DROP COLUMN email;");
}
use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.
the class DbLocksCommandTest method testListLocks.
@Test
public void testListLocks() throws Exception {
final PrintStream printStream = new PrintStream(new ByteArrayOutputStream());
locksCommand.setPrintStream(printStream);
// We can't create locks in the database, so use mocks
final Liquibase liquibase = Mockito.mock(Liquibase.class);
locksCommand.run(new Namespace(ImmutableMap.of("list", true, "release", false)), liquibase);
Mockito.verify(liquibase).reportLocks(printStream);
}
use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.
the class DbLocksCommandTest method testRelease.
@Test
public void testRelease() throws Exception {
// We can't create locks in the database, so use mocks
final Liquibase liquibase = Mockito.mock(Liquibase.class);
locksCommand.run(new Namespace(ImmutableMap.of("list", false, "release", true)), liquibase);
Mockito.verify(liquibase).forceReleaseLocks();
}
Aggregations