Skip to content

Commit

Permalink
Merge pull request #61 from jamesneale/fix/return-string-docker-compo…
Browse files Browse the repository at this point in the history
…sition

Fix dockerComposition to also return a String! ^_^
  • Loading branch information
hpryce committed May 12, 2016
2 parents e482cbf + e360c6a commit f5c37c1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ public void after() {
}
}

public void exec(DockerComposeExecOption options, String containerName,
public String exec(DockerComposeExecOption options, String containerName,
DockerComposeExecArgument arguments) throws IOException, InterruptedException {
dockerCompose().exec(options, containerName, arguments);
return dockerCompose().exec(options, containerName, arguments);
}

public static ImmutableDockerComposeRule.Builder builder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ public static DockerCompositionBuilder of(DockerCompose compose) {
return new DockerCompositionBuilder().dockerCompose(compose);
}

public void exec(DockerComposeExecOption options, String containerName, DockerComposeExecArgument arguments)
public String exec(DockerComposeExecOption options, String containerName, DockerComposeExecArgument arguments)
throws IOException, InterruptedException {
rule.exec(options, containerName, arguments);
return rule.exec(options, containerName, arguments);
}

public DockerPort hostNetworkedPort(int port) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

import static com.google.common.base.Throwables.propagate;
import static com.palantir.docker.compose.connection.waiting.HealthChecks.toHaveAllPortsOpen;
import static com.palantir.docker.compose.execution.DockerComposeExecArgument.arguments;
import static com.palantir.docker.compose.execution.DockerComposeExecOption.options;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;

Expand All @@ -27,6 +30,8 @@
import java.io.IOException;
import java.util.List;
import java.util.function.Consumer;

import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
Expand Down Expand Up @@ -97,4 +102,10 @@ public void can_access_external_port_for_internal_port_of_machine() throws IOExc
});
}

@Ignore // This test will not run on Circle CI because it does not currently support docker-compose exec.
@Test
public void exec_returns_output() throws Exception {
assertThat(composition.exec(options(), CONTAINERS.get(0), arguments("echo", "hello")), is("hello"));
}

}

0 comments on commit f5c37c1

Please sign in to comment.