feat: update more than one LoadBalancer ip
Co-authored-by: kevinpollet <pollet.kevin@gmail.com>
This commit is contained in:
parent
76f42a3013
commit
498e8545b6
4 changed files with 119 additions and 23 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
kubeerror "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
@ -47,3 +48,80 @@ func TestTranslateNotFoundError(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsLoadBalancerIngressEquals(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
aSlice []corev1.LoadBalancerIngress
|
||||
bSlice []corev1.LoadBalancerIngress
|
||||
expectedEqual bool
|
||||
}{
|
||||
{
|
||||
desc: "both slices are empty",
|
||||
expectedEqual: true,
|
||||
},
|
||||
{
|
||||
desc: "not the same length",
|
||||
bSlice: []corev1.LoadBalancerIngress{
|
||||
{IP: "192.168.1.1", Hostname: "traefik"},
|
||||
},
|
||||
expectedEqual: false,
|
||||
},
|
||||
{
|
||||
desc: "same ordered content",
|
||||
aSlice: []corev1.LoadBalancerIngress{
|
||||
{IP: "192.168.1.1", Hostname: "traefik"},
|
||||
},
|
||||
bSlice: []corev1.LoadBalancerIngress{
|
||||
{IP: "192.168.1.1", Hostname: "traefik"},
|
||||
},
|
||||
expectedEqual: true,
|
||||
},
|
||||
{
|
||||
desc: "same unordered content",
|
||||
aSlice: []corev1.LoadBalancerIngress{
|
||||
{IP: "192.168.1.1", Hostname: "traefik"},
|
||||
{IP: "192.168.1.2", Hostname: "traefik2"},
|
||||
},
|
||||
bSlice: []corev1.LoadBalancerIngress{
|
||||
{IP: "192.168.1.2", Hostname: "traefik2"},
|
||||
{IP: "192.168.1.1", Hostname: "traefik"},
|
||||
},
|
||||
expectedEqual: true,
|
||||
},
|
||||
{
|
||||
desc: "different ordered content",
|
||||
aSlice: []corev1.LoadBalancerIngress{
|
||||
{IP: "192.168.1.1", Hostname: "traefik"},
|
||||
{IP: "192.168.1.2", Hostname: "traefik2"},
|
||||
},
|
||||
bSlice: []corev1.LoadBalancerIngress{
|
||||
{IP: "192.168.1.1", Hostname: "traefik"},
|
||||
{IP: "192.168.1.2", Hostname: "traefik"},
|
||||
},
|
||||
expectedEqual: false,
|
||||
},
|
||||
{
|
||||
desc: "different unordered content",
|
||||
aSlice: []corev1.LoadBalancerIngress{
|
||||
{IP: "192.168.1.1", Hostname: "traefik"},
|
||||
{IP: "192.168.1.2", Hostname: "traefik2"},
|
||||
},
|
||||
bSlice: []corev1.LoadBalancerIngress{
|
||||
{IP: "192.168.1.2", Hostname: "traefik3"},
|
||||
{IP: "192.168.1.1", Hostname: "traefik"},
|
||||
},
|
||||
expectedEqual: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
test := test
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
gotEqual := isLoadBalancerIngressEquals(test.aSlice, test.bSlice)
|
||||
assert.Equal(t, test.expectedEqual, gotEqual)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue