use of org.eclipse.jkube.gradle.plugin.TestKubernetesExtension in project jkube by eclipse.
the class KubernetesBuildTaskTest method setUp.
@Before
public void setUp() throws IOException {
// Mock required for environments with no DOCKER available (don't remove)
dockerAccessFactoryMockedConstruction = mockConstruction(DockerAccessFactory.class, (mock, ctx) -> when(mock.createDockerAccess(any())).thenReturn(mock(DockerAccess.class)));
dockerBuildServiceMockedConstruction = mockConstruction(DockerBuildService.class, (mock, ctx) -> {
when(mock.isApplicable()).thenReturn(isBuildServiceApplicable);
if (isBuildError) {
doThrow(new JKubeServiceException("Exception during Build")).when(mock).build(any());
}
});
isBuildServiceApplicable = true;
isBuildError = false;
extension = new TestKubernetesExtension();
when(taskEnvironment.project.getExtensions().getByType(KubernetesExtension.class)).thenReturn(extension);
extension.images = Collections.singletonList(ImageConfiguration.builder().name("foo/bar:latest").build(BuildConfiguration.builder().dockerFile("Dockerfile").build()).build());
}
use of org.eclipse.jkube.gradle.plugin.TestKubernetesExtension in project jkube by eclipse.
the class KubernetesDebugTaskTest method setUp.
@Before
public void setUp() throws IOException {
debugServiceMockedConstruction = mockConstruction(DebugService.class);
extension = new TestKubernetesExtension();
when(taskEnvironment.project.getExtensions().getByType(KubernetesExtension.class)).thenReturn(extension);
}
use of org.eclipse.jkube.gradle.plugin.TestKubernetesExtension in project jkube by eclipse.
the class KubernetesLogTaskTest method setUp.
@Before
public void setUp() throws IOException {
extension = new TestKubernetesExtension();
extension.isUseColor = false;
when(taskEnvironment.project.getExtensions().getByType(KubernetesExtension.class)).thenReturn(extension);
}
use of org.eclipse.jkube.gradle.plugin.TestKubernetesExtension in project jkube by eclipse.
the class KubernetesPushTaskTest method runTask_withSkipPush_shouldDoNothing.
@Test
public void runTask_withSkipPush_shouldDoNothing() throws JKubeServiceException {
// Given
extension = new TestKubernetesExtension() {
@Override
public Property<Boolean> getSkipPush() {
return new DefaultProperty<>(Boolean.class).value(true);
}
};
when(taskEnvironment.project.getExtensions().getByType(KubernetesExtension.class)).thenReturn(extension);
final KubernetesPushTask pushTask = new KubernetesPushTask(KubernetesExtension.class);
when(pushTask.getName()).thenReturn("k8sPush");
// When
pushTask.runTask();
// Then
Assertions.assertThat(dockerBuildServiceMockedConstruction.constructed()).isEmpty();
verify(pushTask.jKubeServiceHub.getBuildService(), times(0)).push(any(), anyInt(), any(), anyBoolean());
verify(taskEnvironment.logger, times(1)).lifecycle(contains("k8s: `k8sPush` task is skipped."));
}
use of org.eclipse.jkube.gradle.plugin.TestKubernetesExtension in project jkube by eclipse.
the class KubernetesUndeployTaskTest method setUp.
@Before
public void setUp() throws IOException {
clusterAccessMockedConstruction = mockConstruction(ClusterAccess.class, (mock, ctx) -> {
final KubernetesClient kubernetesClient = mock(KubernetesClient.class);
when(mock.createDefaultClient()).thenReturn(kubernetesClient);
when(kubernetesClient.getMasterUrl()).thenReturn(new URL("http://kubernetes-cluster"));
});
kubernetesUndeployServiceMockedConstruction = mockConstruction(KubernetesUndeployService.class);
extension = new TestKubernetesExtension();
when(taskEnvironment.project.getExtensions().getByType(KubernetesExtension.class)).thenReturn(extension);
}
Aggregations