Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ workflows:
<<: *always-run
- publish:
requires:
- build
- py3
- mypy3
- circle-all
filters:
branches:
ignore: /.*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ public class ConjurePythonCliTest {

@BeforeEach
public void before() throws IOException {
inputFile = folder.newFile();
inputFile = new File(folder, "file");
assertThat(inputFile.createNewFile()).isTrue();
}

@Test
public void correctlyParseArguments() {
String[] args = {
"generate",
inputFile.getAbsolutePath(),
folder.getRoot().getAbsolutePath(),
folder.getAbsolutePath(),
"--packageName",
"package-name",
"--packageVersion",
Expand All @@ -57,7 +58,7 @@ public void correctlyParseArguments() {
.getCommand();
CliConfiguration expectedConfiguration = CliConfiguration.builder()
.input(inputFile)
.output(folder.getRoot())
.output(folder)
.packageName("package-name")
.packageVersion("0.0.0")
.build();
Expand Down Expand Up @@ -95,7 +96,7 @@ public void makesPackageVersionPythonic() {
String[] args = {
"generate",
inputFile.getAbsolutePath(),
folder.getRoot().getAbsolutePath(),
folder.getAbsolutePath(),
"--packageName=package-name",
"--packageVersion=0.0.0-dev"
};
Expand All @@ -106,7 +107,7 @@ public void makesPackageVersionPythonic() {
.getCommand();
CliConfiguration expectedConfiguration = CliConfiguration.builder()
.input(inputFile)
.output(folder.getRoot())
.output(folder)
.packageName("package-name")
.packageVersion("0.0.0_dev")
.build();
Expand All @@ -115,35 +116,37 @@ public void makesPackageVersionPythonic() {

@Test
public void generatesCode() throws Exception {
File output = folder.newFolder();
String[] args = {
"generate",
"src/test/resources/conjure-api.json",
output.getAbsolutePath(),
folder.getAbsolutePath(),
"--packageName",
"conjure",
"--packageVersion",
"0.0.0"
};
assertThat(new CommandLine(new ConjurePythonCli()).execute(args)).isZero();
assertThat(new File(output, "conjure/conjure_spec/__init__.py").isFile())
assertThat(new File(folder, "conjure/conjure_spec/__init__.py").isFile())
.isTrue();
}

@Test
public void generatesRawSource() throws IOException {
File output = folder.newFolder();
String[] args = {
"generate", "src/test/resources/conjure-api.json", output.getAbsolutePath(), "--rawSource",
"generate", "src/test/resources/conjure-api.json", folder.getAbsolutePath(), "--rawSource",
};
assertThat(new CommandLine(new ConjurePythonCli()).execute(args)).isZero();
assertThat(new File(output, "conjure_spec/__init__.py").isFile()).isTrue();
assertThat(new File(folder, "conjure_spec/__init__.py").isFile()).isTrue();
}

@Test
public void throwsWhenInvalidDefinition() throws Exception {
File input = new File(folder, "input");
File outputDir = new File(folder, "outputDir");
assertThat(input.createNewFile()).isTrue();
assertThat(outputDir.mkdir()).isTrue();
String[] args = {
"generate", folder.newFile().getAbsolutePath(), folder.newFolder().getAbsolutePath(), "--rawSource",
"generate", input.getAbsolutePath(), outputDir.getAbsolutePath(), "--rawSource",
};

AtomicReference<Exception> executionException = new AtomicReference<>();
Expand Down