@Test public void have_tls_environment_variables_set_when_a_docker_machine_is_built_with_tls() { DockerMachine dockerMachine = DockerMachine.remoteMachine() .host("tcp://192.168.99.100") .withTLS("/path/to/certs") .build(); Map<String, String> expected = ImmutableMap.<String, String>builder() .put(DOCKER_HOST, "tcp://192.168.99.100") .put(DOCKER_CERT_PATH, "/path/to/certs") .build(); validateEnvironmentConfiguredDirectly(dockerMachine, expected); }
@Test public void build_a_docker_machine_with_additional_environment_variables() { DockerMachine dockerMachine = DockerMachine.remoteMachine() .host("tcp://192.168.99.100") .withoutTLS() .withAdditionalEnvironmentVariable("SOME_VARIABLE", "SOME_VALUE") .build(); Map<String, String> expected = ImmutableMap.<String, String>builder() .put(DOCKER_HOST, "tcp://192.168.99.100") .put("SOME_VARIABLE", "SOME_VALUE") .build(); validateEnvironmentConfiguredDirectly(dockerMachine, expected); }
@Test public void have_no_tls_environment_variables_when_a_docker_machine_is_built_without_tls() { DockerMachine dockerMachine = DockerMachine.remoteMachine() .host("tcp://192.168.99.100") .withoutTLS() .build(); Map<String, String> expected = ImmutableMap.<String, String>builder() .put(DOCKER_HOST, "tcp://192.168.99.100") .build(); validateEnvironmentConfiguredDirectly(dockerMachine, expected); }
@Test public void throw_exception_when_building_a_docker_machine_without_a_host() { exception.expect(IllegalStateException.class); exception.expectMessage("Missing required environment variables"); exception.expectMessage("DOCKER_HOST"); DockerMachine.remoteMachine() .withoutTLS() .build(); }