Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
eddumelendez committed Jul 29, 2022
1 parent deb5f2b commit afbc537
Showing 1 changed file with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,42 @@ public class DockerComposeOverridesTest {

private static final int SERVICE_PORT = 3000;

private static final String SERVICE_NAME = "alpine_1";
private final String serviceName;

private final boolean localMode;

private final String expectedEnvVar;

private final File[] composeFiles;

public DockerComposeOverridesTest(boolean localMode, String expectedEnvVar, File... composeFiles) {
public DockerComposeOverridesTest(
String serviceName,
boolean localMode,
String expectedEnvVar,
File... composeFiles
) {
this.serviceName = serviceName;
this.localMode = localMode;
this.expectedEnvVar = expectedEnvVar;
this.composeFiles = composeFiles;
}

@Parameters(name = "{index}: local[{0}], composeFiles[{2}], expectedEnvVar[{1}]")
@Parameters(name = "{index}: serviceName[{0}] local[{1}], composeFiles[{3}], expectedEnvVar[{2}]")
public static Iterable<Object[]> data() {
return Arrays.asList(
new Object[][] {
{ true, BASE_ENV_VAR, new File[] { BASE_COMPOSE_FILE } },
{ true, OVERRIDE_ENV_VAR, new File[] { BASE_COMPOSE_FILE, OVERRIDE_COMPOSE_FILE } },
{ false, BASE_ENV_VAR, new File[] { BASE_COMPOSE_FILE } },
{ false, OVERRIDE_ENV_VAR, new File[] { BASE_COMPOSE_FILE, OVERRIDE_COMPOSE_FILE } },
{ "alpine-1", true, BASE_ENV_VAR, new File[] { BASE_COMPOSE_FILE } },
{ "alpine-1", true, OVERRIDE_ENV_VAR, new File[] { BASE_COMPOSE_FILE, OVERRIDE_COMPOSE_FILE } },
{ "alpine_1", false, BASE_ENV_VAR, new File[] { BASE_COMPOSE_FILE } },
{ "alpine_1", false, OVERRIDE_ENV_VAR, new File[] { BASE_COMPOSE_FILE, OVERRIDE_COMPOSE_FILE } },
}
);
}

@Before
public void setUp() {
if (localMode) {
Assumptions
.assumeThat(LocalDockerCompose.executableExists())
.as("docker-compose executable exists")
.isTrue();
Assumptions.assumeThat(LocalDockerCompose.executableExists()).as("docker executable exists").isTrue();
}
}

Expand All @@ -75,7 +78,7 @@ public void test() {
try (
DockerComposeContainer compose = new DockerComposeContainer(composeFiles)
.withLocalCompose(localMode)
.withExposedService(SERVICE_NAME, SERVICE_PORT)
.withExposedService(serviceName, SERVICE_PORT)
) {
compose.start();

Expand All @@ -86,8 +89,8 @@ public void test() {
Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);

Socket socket = new Socket(
compose.getServiceHost(SERVICE_NAME, SERVICE_PORT),
compose.getServicePort(SERVICE_NAME, SERVICE_PORT)
compose.getServiceHost(serviceName, SERVICE_PORT),
compose.getServicePort(serviceName, SERVICE_PORT)
);
return new BufferedReader(new InputStreamReader(socket.getInputStream()));
}
Expand Down

0 comments on commit afbc537

Please sign in to comment.