1
// Copyright Istio Authors
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
7
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
20
corev1 "k8s.io/api/core/v1"
21
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23
"istio.io/istio/pkg/test/util/assert"
26
func TestGetPodIPIfPodIPPresent(t *testing.T) {
28
ObjectMeta: metav1.ObjectMeta{
35
Status: corev1.PodStatus{
40
podIPs := GetPodIPsIfPresent(pod)
41
assert.Equal(t, len(podIPs), 1)
44
func TestGetPodIPsIfPodIPPresent(t *testing.T) {
46
ObjectMeta: metav1.ObjectMeta{
53
Status: corev1.PodStatus{
55
PodIPs: []corev1.PodIP{{IP: "2.2.2.2"}, {IP: "3.3.3.3"}},
59
podIPs := GetPodIPsIfPresent(pod)
60
assert.Equal(t, len(podIPs), 2)
63
func TestGetPodIPsIfNoPodIPPresent(t *testing.T) {
65
ObjectMeta: metav1.ObjectMeta{
72
Status: corev1.PodStatus{},
75
podIPs := GetPodIPsIfPresent(pod)
76
assert.Equal(t, len(podIPs), 0)