Skip to content

Commit

Permalink
Merge pull request #30257 from kdubois/main
Browse files Browse the repository at this point in the history
Improve Quarkus CLI tests to check for --native flag output
  • Loading branch information
gsmet authored Jan 10, 2023
2 parents e7856af + b8479af commit 54901e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quarkus.cli.image;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
Expand Down Expand Up @@ -94,6 +95,10 @@ public void testUsage() throws Exception {
// 1 image --dry-run
result = CliDriver.execute(project, "image", "--dry-run");
assertEquals(CommandLine.ExitCode.OK, result.getExitCode(), "Expected OK return code." + result);
assertFalse(result.getStdout().contains("-Dquarkus.package.type=native"));
result = CliDriver.execute(project, "image", "--native", "--dry-run");
assertEquals(CommandLine.ExitCode.OK, result.getExitCode(), "Expected OK return code." + result);
assertTrue(result.getStdout().contains("-Dquarkus.package.type=native"));

// 2 image build --dry-run
result = CliDriver.execute(project, "image", "build", "--dry-run");
Expand Down Expand Up @@ -121,11 +126,13 @@ public void testUsage() throws Exception {
assertTrue(result.getStdout().contains("--builder=openshift"));
assertTrue(result.getStdout().contains("--init-script="));

result = CliDriver.execute(project, "image", "build", "--group=mygroup", "--name=myname", "--tag=1.0", "--dry-run");
result = CliDriver.execute(project, "image", "build", "--group=mygroup", "--name=myname", "--tag=1.0", "--native",
"--dry-run");
assertEquals(CommandLine.ExitCode.OK, result.getExitCode(), "Expected OK return code." + result);
assertTrue(result.getStdout().contains("-Dquarkus.container-image.group=mygroup"));
assertTrue(result.getStdout().contains("-Dquarkus.container-image.name=myname"));
assertTrue(result.getStdout().contains("-Dquarkus.container-image.tag=1.0"));
assertTrue(result.getStdout().contains("-Dquarkus.package.type=native"));

// 3 image push --dry-run
result = CliDriver.execute(project, "image", "push", "--dry-run");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quarkus.cli.image;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.nio.file.Path;
Expand Down Expand Up @@ -47,14 +48,21 @@ public void testUsage() throws Exception {
// 1 image --dry-run
result = CliDriver.execute(project, "image", "--dry-run");
assertEquals(CommandLine.ExitCode.OK, result.getExitCode(), "Expected OK return code." + result);
assertTrue(result.getStdout().contains("quarkus:image-build"));
assertFalse(result.getStdout().contains("-Dnative"));
result = CliDriver.execute(project, "image", "--native", "--dry-run");
assertTrue(result.getStdout().contains("-Dnative"));

// 2 image build --dry-run
result = CliDriver.execute(project, "image", "build", "--dry-run");
assertEquals(CommandLine.ExitCode.OK, result.getExitCode(), "Expected OK return code." + result);
result = CliDriver.execute(project, "image", "build", "--group=mygroup", "--name=myname", "--tag=1.0", "--dry-run");
result = CliDriver.execute(project, "image", "build", "--group=mygroup", "--name=myname", "--tag=1.0", "--native",
"--dry-run");
assertEquals(CommandLine.ExitCode.OK, result.getExitCode(), "Expected OK return code." + result);
assertTrue(result.getStdout().contains("-Dquarkus.container-image.group=mygroup"));
assertTrue(result.getStdout().contains("-Dquarkus.container-image.name=myname"));
assertTrue(result.getStdout().contains("-Dquarkus.container-image.tag=1.0"));
assertTrue(result.getStdout().contains("-Dnative"));

// 3 image push --dry-run
result = CliDriver.execute(project, "image", "push", "--dry-run");
Expand Down

0 comments on commit 54901e3

Please sign in to comment.