|
9 | 9 | "fmt"
|
10 | 10 | "testing"
|
11 | 11 |
|
| 12 | + "github.com/stretchr/testify/require" |
12 | 13 | corev1 "k8s.io/api/core/v1"
|
13 | 14 | discoveryv1 "k8s.io/api/discovery/v1"
|
14 | 15 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
@@ -50,10 +51,59 @@ func TestGetIREndpointsFromEndpointSlices(t *testing.T) {
|
50 | 51 | {Name: ptr.To("http"), Port: ptr.To(int32(80)), Protocol: ptr.To(corev1.ProtocolTCP)},
|
51 | 52 | },
|
52 | 53 | },
|
| 54 | + { |
| 55 | + ObjectMeta: metav1.ObjectMeta{Name: "slice3"}, |
| 56 | + AddressType: discoveryv1.AddressTypeIPv6, |
| 57 | + Endpoints: []discoveryv1.Endpoint{ |
| 58 | + { |
| 59 | + Addresses: []string{"2001:db8::2"}, |
| 60 | + Conditions: discoveryv1.EndpointConditions{ |
| 61 | + Ready: ptr.To(false), |
| 62 | + }, |
| 63 | + }, |
| 64 | + }, |
| 65 | + Ports: []discoveryv1.EndpointPort{ |
| 66 | + {Name: ptr.To("http"), Port: ptr.To(int32(80)), Protocol: ptr.To(corev1.ProtocolTCP)}, |
| 67 | + }, |
| 68 | + }, |
| 69 | + { |
| 70 | + ObjectMeta: metav1.ObjectMeta{Name: "slice4"}, |
| 71 | + AddressType: discoveryv1.AddressTypeIPv6, |
| 72 | + Endpoints: []discoveryv1.Endpoint{ |
| 73 | + { |
| 74 | + Addresses: []string{"2001:db8::3"}, |
| 75 | + Conditions: discoveryv1.EndpointConditions{ |
| 76 | + Ready: ptr.To(false), |
| 77 | + Serving: ptr.To(true), |
| 78 | + Terminating: ptr.To(true), |
| 79 | + }, |
| 80 | + }, |
| 81 | + }, |
| 82 | + Ports: []discoveryv1.EndpointPort{ |
| 83 | + {Name: ptr.To("http"), Port: ptr.To(int32(80)), Protocol: ptr.To(corev1.ProtocolTCP)}, |
| 84 | + }, |
| 85 | + }, |
| 86 | + { |
| 87 | + ObjectMeta: metav1.ObjectMeta{Name: "slice5"}, |
| 88 | + AddressType: discoveryv1.AddressTypeIPv6, |
| 89 | + Endpoints: []discoveryv1.Endpoint{ |
| 90 | + { |
| 91 | + Addresses: []string{"2001:db8::4"}, |
| 92 | + Conditions: discoveryv1.EndpointConditions{ |
| 93 | + Ready: ptr.To(false), |
| 94 | + Serving: ptr.To(false), |
| 95 | + Terminating: ptr.To(true), |
| 96 | + }, |
| 97 | + }, |
| 98 | + }, |
| 99 | + Ports: []discoveryv1.EndpointPort{ |
| 100 | + {Name: ptr.To("http"), Port: ptr.To(int32(80)), Protocol: ptr.To(corev1.ProtocolTCP)}, |
| 101 | + }, |
| 102 | + }, |
53 | 103 | },
|
54 | 104 | portName: "http",
|
55 | 105 | portProtocol: corev1.ProtocolTCP,
|
56 |
| - expectedEndpoints: 3, |
| 106 | + expectedEndpoints: 4, |
57 | 107 | expectedAddrType: ir.IP,
|
58 | 108 | },
|
59 | 109 | {
|
@@ -174,6 +224,8 @@ func TestGetIREndpointsFromEndpointSlices(t *testing.T) {
|
174 | 224 | }
|
175 | 225 |
|
176 | 226 | fmt.Println()
|
| 227 | + require.Len(t, endpoints, tt.expectedEndpoints) |
| 228 | + require.Equal(t, tt.expectedAddrType, *addrType) |
177 | 229 | })
|
178 | 230 | }
|
179 | 231 | }
|
0 commit comments