forked from testcontainers/testcontainers-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
97 changed files
with
420 additions
and
252 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
37 changes: 37 additions & 0 deletions
37
core/src/main/java/org/testcontainers/containers/ComposeCommand.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,37 @@ | ||
package org.testcontainers.containers; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import java.util.Set; | ||
|
||
class ComposeCommand { | ||
|
||
static String getDownCommand(ComposeDelegate.ComposeVersion composeVersion, Set<String> options) { | ||
String composeOptions = optionsAsString(options); | ||
if (composeOptions == null || composeOptions.equals("")) { | ||
return composeVersion == ComposeDelegate.ComposeVersion.V1 ? "down" : "compose down"; | ||
} | ||
String cmd = composeVersion == ComposeDelegate.ComposeVersion.V1 ? "%s down" : "compose %s down"; | ||
return String.format(cmd, composeOptions); | ||
} | ||
|
||
static String getUpCommand(ComposeDelegate.ComposeVersion composeVersion, Set<String> options) { | ||
String composeOptions = optionsAsString(options); | ||
if (composeOptions == null || composeOptions.equals("")) { | ||
return composeVersion == ComposeDelegate.ComposeVersion.V1 ? "up -d" : "compose up -d"; | ||
} | ||
String cmd = composeVersion == ComposeDelegate.ComposeVersion.V1 ? "%s up -d" : "compose %s up -d"; | ||
return String.format(cmd, composeOptions); | ||
} | ||
|
||
private static String optionsAsString(final Set<String> options) { | ||
String optionsString = String.join(" ", options); | ||
if (!optionsString.isEmpty()) { | ||
// ensures that there is a space between the options and 'up' if options are passed. | ||
return optionsString; | ||
} else { | ||
// otherwise two spaces would appear between 'docker-compose' and 'up' | ||
return StringUtils.EMPTY; | ||
} | ||
} | ||
} |
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
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
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
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
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
35 changes: 35 additions & 0 deletions
35
core/src/test/java/org/testcontainers/containers/ComposeProfilesOptionTest.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,35 @@ | ||
package org.testcontainers.containers; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
import java.io.File; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@RunWith(Parameterized.class) | ||
public class ComposeProfilesOptionTest { | ||
|
||
@Parameterized.Parameters(name = "{0}") | ||
public static Boolean[] local() { | ||
return new Boolean[] { Boolean.TRUE, Boolean.FALSE }; | ||
} | ||
|
||
@Parameterized.Parameter | ||
public boolean local; | ||
|
||
public static final File COMPOSE_FILE = new File("src/test/resources/compose-profile-option/compose-test.yml"); | ||
|
||
@Test | ||
public void testProfileOption() { | ||
try ( | ||
ComposeContainer compose = new ComposeContainer(COMPOSE_FILE) | ||
.withOptions("--profile=cache") | ||
.withLocalCompose(true) | ||
) { | ||
compose.start(); | ||
assertThat(compose.listChildContainers()).hasSize(1); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
core/src/test/java/org/testcontainers/containers/DockerComposeProfilesOptionTest.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,35 @@ | ||
package org.testcontainers.containers; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
import java.io.File; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@RunWith(Parameterized.class) | ||
public class DockerComposeProfilesOptionTest { | ||
|
||
@Parameterized.Parameters(name = "{0}") | ||
public static Boolean[] local() { | ||
return new Boolean[] { Boolean.TRUE, Boolean.FALSE }; | ||
} | ||
|
||
@Parameterized.Parameter | ||
public boolean local; | ||
|
||
public static final File COMPOSE_FILE = new File("src/test/resources/compose-profile-option/compose-test.yml"); | ||
|
||
@Test | ||
public void testProfileOption() { | ||
try ( | ||
DockerComposeContainer<?> compose = new DockerComposeContainer<>(COMPOSE_FILE) | ||
.withOptions("--profile=cache") | ||
.withLocalCompose(this.local) | ||
) { | ||
compose.start(); | ||
assertThat(compose.listChildContainers()).hasSize(1); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
core/src/test/resources/compose-profile-option/compose-test.yml
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,11 @@ | ||
services: | ||
redis: | ||
image: redis | ||
profiles: | ||
- cache | ||
db: | ||
image: mysql:8.0.36 | ||
environment: | ||
MYSQL_RANDOM_ROOT_PASSWORD: "true" | ||
profiles: | ||
- db |
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
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
description = "Examples for docs" | ||
|
||
dependencies { | ||
api "io.lettuce:lettuce-core:6.3.1.RELEASE" | ||
api "io.lettuce:lettuce-core:6.3.2.RELEASE" | ||
|
||
testImplementation "junit:junit:4.13.2" | ||
testImplementation project(":testcontainers") | ||
testImplementation 'org.assertj:assertj-core:3.25.3' | ||
testImplementation 'org.assertj:assertj-core:3.26.3' | ||
} |
Oops, something went wrong.