Created
January 29, 2019 09:24
-
-
Save lordofthejars/a0bca802750f433d40036ec4ac3f789d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@ExtendWith | |
({ | |
OpenShiftConditionExtension.class, // Checks if there is an OpenShift cluster running | |
GitExtension.class, // Clones project to temporal directory | |
OpenShiftInjector.class // Injects OpeShift client to do assertions | |
}) | |
@GitClone("https://github.com/openshift/nodejs-ex") // Project to clone | |
public class CreateDeployTest { | |
private final Odo odo = new Odo(new OdoConfiguration()); // Creates Odo instance | |
@AfterEach | |
public void removeComponentsAndRoutes(Path cloneRepo) { // Clean components created by odo | |
final UrlDeleteCommand urlDeleteCommand = new UrlDeleteCommand.Builder("route").build(); | |
final UrlCommand urlCommand = new UrlCommand | |
.Builder(urlDeleteCommand) | |
.build(); | |
odo.execute(cloneRepo, urlCommand); | |
final DeleteCommand deleteCommand = new DeleteCommand.Builder("nodejs").build(); | |
odo.execute(cloneRepo, deleteCommand); | |
} | |
@Test | |
public void should_create_and_deploy_apps(Path cloneRepo, OpenShiftOperation openShiftOperation) { | |
// Given | |
final CreateCommand createCommand = new CreateCommand | |
.Builder("nodejs") | |
.withComponentName("nodejs") | |
.build(); | |
final PushCommand pushCommand = new PushCommand | |
.Builder() | |
.build(); | |
final UrlCreateCommand urlCreateCommand = new UrlCreateCommand | |
.Builder() | |
.withComponentName("route") | |
.build(); | |
final UrlCommand urlCommand = new UrlCommand | |
.Builder(urlCreateCommand) | |
.build(); | |
// When | |
odo.execute(cloneRepo, createCommand); | |
odo.execute(cloneRepo, pushCommand); | |
odo.execute(cloneRepo, urlCommand); | |
// Then | |
final Optional<String> exposedRoute = openShiftOperation.getUrlOfRouteStartingWith("route"); | |
assertThat(exposedRoute).isNotEmpty(); | |
UrlAssertion.assertThat(exposedRoute.get()).isUpAndRunning(); // Custom assertj assertion that validate that the service (nodejs) is up and running | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment