Skip to content

Commit 1ce0b1d

Browse files
authored
Check if docker-compose is available (#9060)
1 parent 2758b51 commit 1ce0b1d

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

core/src/test/java/org/testcontainers/containers/DockerComposeProfilesOptionTest.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package org.testcontainers.containers;
22

3+
import org.assertj.core.api.Assumptions;
4+
import org.junit.Before;
35
import org.junit.Test;
46
import org.junit.runner.RunWith;
57
import org.junit.runners.Parameterized;
8+
import org.testcontainers.utility.CommandLine;
69

710
import java.io.File;
811

@@ -17,16 +20,26 @@ public static Boolean[] local() {
1720
}
1821

1922
@Parameterized.Parameter
20-
public boolean local;
23+
public boolean localMode;
2124

2225
public static final File COMPOSE_FILE = new File("src/test/resources/compose-profile-option/compose-test.yml");
2326

27+
@Before
28+
public void setUp() {
29+
if (this.localMode) {
30+
Assumptions
31+
.assumeThat(CommandLine.executableExists(DockerComposeContainer.COMPOSE_EXECUTABLE))
32+
.as("docker-compose executable exists")
33+
.isTrue();
34+
}
35+
}
36+
2437
@Test
2538
public void testProfileOption() {
2639
try (
2740
DockerComposeContainer<?> compose = new DockerComposeContainer<>(COMPOSE_FILE)
2841
.withOptions("--profile=cache")
29-
.withLocalCompose(this.local)
42+
.withLocalCompose(this.localMode)
3043
) {
3144
compose.start();
3245
assertThat(compose.listChildContainers()).hasSize(1);

core/src/test/java/org/testcontainers/junit/DockerComposeContainerWithOptionsTest.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package org.testcontainers.junit;
22

33
import com.google.common.collect.ImmutableSet;
4+
import org.assertj.core.api.Assumptions;
5+
import org.junit.Before;
46
import org.junit.Test;
57
import org.junit.runner.RunWith;
68
import org.junit.runners.Parameterized;
79
import org.testcontainers.containers.DockerComposeContainer;
10+
import org.testcontainers.utility.CommandLine;
811

912
import java.io.File;
1013
import java.util.Set;
@@ -19,19 +22,19 @@ public class DockerComposeContainerWithOptionsTest {
1922

2023
public DockerComposeContainerWithOptionsTest(
2124
final File composeFile,
22-
final boolean local,
25+
final boolean localMode,
2326
final Set<String> options,
2427
final boolean expectError
2528
) {
2629
this.composeFile = composeFile;
27-
this.local = local;
30+
this.localMode = localMode;
2831
this.options = options;
2932
this.expectError = expectError;
3033
}
3134

3235
private final File composeFile;
3336

34-
private final boolean local;
37+
private final boolean localMode;
3538

3639
private final Set<String> options;
3740

@@ -73,12 +76,22 @@ public static Object[][] params() {
7376
};
7477
}
7578

79+
@Before
80+
public void setUp() {
81+
if (this.localMode) {
82+
Assumptions
83+
.assumeThat(CommandLine.executableExists(DockerComposeContainer.COMPOSE_EXECUTABLE))
84+
.as("docker-compose executable exists")
85+
.isTrue();
86+
}
87+
}
88+
7689
@Test
7790
public void performTest() {
7891
try (
7992
DockerComposeContainer<?> environment = new DockerComposeContainer<>(composeFile)
8093
.withOptions(options.stream().toArray(String[]::new))
81-
.withLocalCompose(local)
94+
.withLocalCompose(localMode)
8295
) {
8396
environment.start();
8497
assertThat(expectError).isEqualTo(false);

0 commit comments

Comments
 (0)