-
-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add coverage for text plugin command
- Loading branch information
Showing
2 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
schemacrawler-text/src/test/java/schemacrawler/test/PluginCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package schemacrawler.test; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static schemacrawler.test.utility.FileHasContent.classpathResource; | ||
import static schemacrawler.test.utility.FileHasContent.hasSameContentAs; | ||
import static schemacrawler.test.utility.FileHasContent.outputOf; | ||
import java.util.Collection; | ||
import org.junit.jupiter.api.Test; | ||
import schemacrawler.test.utility.ResolveTestContext; | ||
import schemacrawler.test.utility.TestContext; | ||
import schemacrawler.test.utility.TestWriter; | ||
import schemacrawler.tools.command.text.schema.SchemaTextCommandProvider; | ||
import schemacrawler.tools.executable.commandline.PluginCommand; | ||
import schemacrawler.tools.executable.commandline.PluginCommandOption; | ||
|
||
@ResolveTestContext | ||
public class PluginCommandTest { | ||
|
||
@Test | ||
public void testSchemaTextCommandProviderPluginCommand(final TestContext testContext) { | ||
final PluginCommand pluginCommand = new SchemaTextCommandProvider().getCommandLineCommand(); | ||
|
||
assertThat(pluginCommand.getName(), is("command:schema")); | ||
|
||
final TestWriter testout = new TestWriter(); | ||
try (final TestWriter out = testout) { | ||
out.println(pluginCommand.getHelpHeader()); | ||
final String[] helpDescription = pluginCommand.getHelpDescription().get(); | ||
writeStringArray(out, helpDescription); | ||
out.println(); | ||
final Collection<PluginCommandOption> options = pluginCommand.getOptions(); | ||
for (final PluginCommandOption pluginCommandOption : options) { | ||
out.println(pluginCommandOption.getName()); | ||
final String[] optionHelpText = pluginCommandOption.getHelpText(); | ||
writeStringArray(out, optionHelpText); | ||
out.println(); | ||
} | ||
final String[] helpFooter = pluginCommand.getHelpFooter().get(); | ||
writeStringArray(out, helpFooter); | ||
} | ||
assertThat( | ||
outputOf(testout), hasSameContentAs(classpathResource(testContext.testMethodFullName()))); | ||
} | ||
|
||
private void writeStringArray(final TestWriter out, final String[] helpFooter) { | ||
for (final String helpLine : helpFooter) { | ||
out.println(helpLine); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...wler-text/src/test/resources/PluginCommandTest.testSchemaTextCommandProviderPluginCommand
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
** Generate text output to show details of a schema | ||
Applies to all commands that show schema information | ||
|
||
no-info | ||
Hide or show SchemaCrawler header and database information | ||
--no-info=<boolean> | ||
<boolean> can be true or false | ||
Optional, defaults to false | ||
|
||
no-remarks | ||
Hide or show table and column remarks | ||
--no-remarks=<boolean> | ||
<boolean> can be true or false | ||
Optional, defaults to false | ||
|
||
portable-names | ||
Allow for easy comparison between databases, by hiding or showing foreign key names, constraint names, trigger names, specific names for routines, or index and primary key names, and fully-qualified table names | ||
--portable-names=<boolean> | ||
<boolean> can be true or false | ||
Optional, defaults to false | ||
|
||
sort-columns | ||
Sort columns in a table alphabetically | ||
--sort-columns=<sortcolumns> | ||
<sortcolumns> can be true or false | ||
Optional, defaults to false | ||
|
||
sort-tables | ||
Sort tables alphabetically | ||
--sort-tables=<sorttables> | ||
<sorttables> can be true or false | ||
Optional, defaults to true | ||
|
||
sort-routines | ||
Sort routines alphabetically | ||
--sort-routines=<sortroutines> | ||
<sortroutines> can be true or false | ||
Optional, defaults to true | ||
|
||
Add command options to the `execute` command in the SchemaCrawler Shell |