Fix broken tests

This commit is contained in:
Georgios Andrianakis
2018-11-16 10:56:41 +02:00
parent b39997a820
commit af9e236787

View File

@@ -18,6 +18,7 @@
package org.springframework.cloud.kubernetes.discovery
import io.fabric8.kubernetes.api.model.EndpointsBuilder
import io.fabric8.kubernetes.api.model.ServiceBuilder
import io.fabric8.kubernetes.client.Config
import io.fabric8.kubernetes.client.KubernetesClient
import io.fabric8.kubernetes.server.mock.KubernetesMockServer
@@ -59,6 +60,15 @@ class KubernetesDiscoveryClientTest extends Specification {
.addNewPort("http",80,"TCP")
.endSubset()
.build()).once()
and:
mockServer.expect().get().withPath("/api/v1/namespaces/test/services/endpoint").andReturn(200, new ServiceBuilder()
.withNewMetadata()
.withName("endpoint")
.withLabels(new HashMap<String, String>() {{
put("l", "v")
}})
.endMetadata()
.build()).once()
DiscoveryClient discoveryClient = new KubernetesDiscoveryClient(mockClient, new KubernetesDiscoveryProperties())
when:
@@ -88,6 +98,16 @@ class KubernetesDiscoveryClientTest extends Specification {
.endSubset()
.build()).once()
and:
mockServer.expect().get().withPath("/api/v1/namespaces/test/services/endpoint").andReturn(200, new ServiceBuilder()
.withNewMetadata()
.withName("endpoint")
.withLabels(new HashMap<String, String>() {{
put("l", "v")
}})
.endMetadata()
.build()).once()
DiscoveryClient discoveryClient = new KubernetesDiscoveryClient(mockClient, new KubernetesDiscoveryProperties())
when:
List<ServiceInstance> instances = discoveryClient.getInstances("endpoint")