NGINX Ingress Provider
Co-authored-by: Kevin Pollet <pollet.kevin@gmail.com>
This commit is contained in:
parent
b39ee8ede5
commit
9bd5c61782
32 changed files with 3894 additions and 18 deletions
77
pkg/provider/kubernetes/ingress-nginx/convert_test.go
Normal file
77
pkg/provider/kubernetes/ingress-nginx/convert_test.go
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
package ingressnginx
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
netv1 "k8s.io/api/networking/v1"
|
||||
"k8s.io/utils/ptr"
|
||||
)
|
||||
|
||||
func Test_convertSlice_corev1_to_networkingv1(t *testing.T) {
|
||||
g := []corev1.LoadBalancerIngress{
|
||||
{
|
||||
IP: "132456",
|
||||
Hostname: "foo",
|
||||
Ports: []corev1.PortStatus{
|
||||
{
|
||||
Port: 123,
|
||||
Protocol: "https",
|
||||
Error: ptr.To("test"),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, err := convertSlice[netv1.IngressLoadBalancerIngress](g)
|
||||
require.NoError(t, err)
|
||||
|
||||
expected := []netv1.IngressLoadBalancerIngress{
|
||||
{
|
||||
IP: "132456",
|
||||
Hostname: "foo",
|
||||
Ports: []netv1.IngressPortStatus{
|
||||
{
|
||||
Port: 123,
|
||||
Protocol: "https",
|
||||
Error: ptr.To("test"),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
func Test_convert(t *testing.T) {
|
||||
g := &corev1.LoadBalancerIngress{
|
||||
IP: "132456",
|
||||
Hostname: "foo",
|
||||
Ports: []corev1.PortStatus{
|
||||
{
|
||||
Port: 123,
|
||||
Protocol: "https",
|
||||
Error: ptr.To("test"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, err := convert[netv1.IngressLoadBalancerIngress](g)
|
||||
require.NoError(t, err)
|
||||
|
||||
expected := &netv1.IngressLoadBalancerIngress{
|
||||
IP: "132456",
|
||||
Hostname: "foo",
|
||||
Ports: []netv1.IngressPortStatus{
|
||||
{
|
||||
Port: 123,
|
||||
Protocol: "https",
|
||||
Error: ptr.To("test"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue