use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class DeploymentConfigHandlerTest method get_withNoImagesAndNoControllerName_shouldThrowException.
@Test
public void get_withNoImagesAndNoControllerName_shouldThrowException() {
// Given
final ResourceConfig resourceConfig = resourceConfigBuilder.build();
final List<ImageConfiguration> images = Collections.emptyList();
// When
final IllegalArgumentException result = assertThrows(IllegalArgumentException.class, () -> deploymentConfigHandler.get(resourceConfig, images));
// Then
assertThat(result).hasMessage("No controller name is specified!");
}
use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class DeploymentConfigHandlerTest method get_withImages_shouldReturnConfigWithContainers.
@Test
public void get_withImages_shouldReturnConfigWithContainers() {
// Given
final ResourceConfig resourceConfig = resourceConfigBuilder.controllerName("controller").build();
final List<ImageConfiguration> images = Arrays.asList(ImageConfiguration.builder().name("busybox").build(BuildConfiguration.builder().build()).build(), ImageConfiguration.builder().name("jkubeio/java:latest").build(BuildConfiguration.builder().build()).build());
// When
final DeploymentConfig result = deploymentConfigHandler.get(resourceConfig, images);
// Then
assertThat(result).hasFieldOrPropertyWithValue("metadata.name", "controller").extracting("spec.template.spec.containers").asList().hasSize(2).extracting("image", "name").containsExactly(new Tuple("busybox:latest", "g-a"), new Tuple("jkubeio/java:latest", "jkubeio-a"));
}
use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class DeploymentHandlerTest method deploymentTemplateHandlerTest.
@Test
public void deploymentTemplateHandlerTest() {
ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").controllerName("testing").serviceAccount("test-account").replicas(5).volumes(volumes1).build();
Deployment deployment = deploymentHandler.get(config, images);
// Assertion
assertNotNull(deployment.getSpec());
assertNotNull(deployment.getMetadata());
assertEquals(5, deployment.getSpec().getReplicas().intValue());
assertNotNull(deployment.getSpec().getTemplate());
assertEquals("testing", deployment.getMetadata().getName());
assertEquals("test-account", deployment.getSpec().getTemplate().getSpec().getServiceAccountName());
assertFalse(deployment.getSpec().getTemplate().getSpec().getVolumes().isEmpty());
assertEquals("test", deployment.getSpec().getTemplate().getSpec().getVolumes().get(0).getName());
assertEquals("/test/path", deployment.getSpec().getTemplate().getSpec().getVolumes().get(0).getHostPath().getPath());
assertNotNull(deployment.getSpec().getTemplate().getSpec().getContainers());
}
use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class DeploymentHandlerTest method deploymentTemplateHandlerWithInvalidNameTest.
@Test(expected = IllegalArgumentException.class)
public void deploymentTemplateHandlerWithInvalidNameTest() {
// with invalid controller name
ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").controllerName("TesTing").serviceAccount("test-account").replicas(5).volumes(volumes1).build();
deploymentHandler.get(config, images);
}
use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class DeploymentHandlerTest method deploymentTemplateHandlerWithoutControllerTest.
@Test(expected = IllegalArgumentException.class)
public void deploymentTemplateHandlerWithoutControllerTest() {
// without controller name
ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").serviceAccount("test-account").replicas(5).volumes(volumes1).build();
deploymentHandler.get(config, images);
}
Aggregations