use of org.testcontainers.containers.ContainerState in project testcontainers-java by testcontainers.
the class DockerComposePassthroughTest method testContainerInstanceProperties.
@Test
public void testContainerInstanceProperties() {
final ContainerState container = waitStrategy.getContainer();
// check environment variable was set
assertThat("Environment variable set correctly", Arrays.asList(Objects.requireNonNull(container.getContainerInfo().getConfig().getEnv())), hasItem("bar=bar"));
// check other container properties
assertNotNull("Container id is not null", container.getContainerId());
assertNotNull("Port mapped", container.getMappedPort(3000));
assertThat("Exposed Ports", container.getExposedPorts(), hasItem(3000));
}
use of org.testcontainers.containers.ContainerState in project testcontainers-java by testcontainers.
the class AuthenticatedImagePullTest method testThatAuthLocatorIsUsedForDockerComposePull.
@Test
public void testThatAuthLocatorIsUsedForDockerComposePull() throws IOException {
// Prepare a simple temporary Docker Compose manifest which requires our custom private image
Path tempFile = getLocalTempFile(".docker-compose.yml");
@Language("yaml") String composeFileContent = "version: '2.0'\n" + "services:\n" + " privateservice:\n" + " command: /bin/sh -c 'sleep 60'\n" + " image: " + testImageName.asCanonicalNameString();
Files.write(tempFile, composeFileContent.getBytes());
// Start the docker compose project, which will require an authenticated pull
try (final DockerComposeContainer<?> compose = new DockerComposeContainer<>(tempFile.toFile())) {
compose.start();
assertTrue("container started following an authenticated pull", compose.getContainerByServiceName("privateservice_1").map(ContainerState::isRunning).orElse(false));
}
}
Aggregations