From f4d0d23a24d5ec359e7680e16ff1b9206cf57dd0 Mon Sep 17 00:00:00 2001 From: Steve Sloka Date: Tue, 19 May 2020 12:31:29 -0400 Subject: [PATCH] add missing projectcontour.io/ingress.class annotation tests (#2536) Signed-off-by: Steve Sloka --- internal/annotation/annotations_test.go | 24 +++++++++ internal/dag/cache_test.go | 72 +++++++++++++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/internal/annotation/annotations_test.go b/internal/annotation/annotations_test.go index 890c6b21275..8c69b7de5d0 100644 --- a/internal/annotation/annotations_test.go +++ b/internal/annotation/annotations_test.go @@ -496,6 +496,18 @@ func TestMatchIngressClass(t *testing.T) { }, want: []bool{false, false}, }, + "ingress nginx projectcontour.io/ingress.class": { + fixture: &v1beta1.Ingress{ + ObjectMeta: metav1.ObjectMeta{ + Name: "incorrect", + Namespace: "default", + Annotations: map[string]string{ + "projectcontour.io/ingress.class": "nginx", + }, + }, + }, + want: []bool{false, false}, + }, "ingress contour kubernetes.io/ingress.class": { fixture: &v1beta1.Ingress{ ObjectMeta: metav1.ObjectMeta{ @@ -520,6 +532,18 @@ func TestMatchIngressClass(t *testing.T) { }, want: []bool{true, true}, }, + "ingress contour projectcontour.io/ingress.class": { + fixture: &v1beta1.Ingress{ + ObjectMeta: metav1.ObjectMeta{ + Name: "incorrect", + Namespace: "default", + Annotations: map[string]string{ + "projectcontour.io/ingress.class": DEFAULT_INGRESS_CLASS, + }, + }, + }, + want: []bool{true, true}, + }, "no annotation": { fixture: &v1beta1.Ingress{ ObjectMeta: metav1.ObjectMeta{ diff --git a/internal/dag/cache_test.go b/internal/dag/cache_test.go index a04468060fb..6429f92742d 100644 --- a/internal/dag/cache_test.go +++ b/internal/dag/cache_test.go @@ -580,6 +580,18 @@ func TestKubernetesCacheInsert(t *testing.T) { }, want: false, }, + "insert ingress incorrect projectcontour.io/ingress.class": { + obj: &v1beta1.Ingress{ + ObjectMeta: metav1.ObjectMeta{ + Name: "incorrect", + Namespace: "default", + Annotations: map[string]string{ + "projectcontour.io/ingress.class": "nginx", + }, + }, + }, + want: false, + }, "insert ingress explicit kubernetes.io/ingress.class": { obj: &v1beta1.Ingress{ ObjectMeta: metav1.ObjectMeta{ @@ -604,6 +616,18 @@ func TestKubernetesCacheInsert(t *testing.T) { }, want: true, }, + "insert ingress explicit projectcontour.io/ingress.class": { + obj: &v1beta1.Ingress{ + ObjectMeta: metav1.ObjectMeta{ + Name: "incorrect", + Namespace: "default", + Annotations: map[string]string{ + "projectcontour.io/ingress.class": annotation.DEFAULT_INGRESS_CLASS, + }, + }, + }, + want: true, + }, "insert ingressroute empty ingress annotation": { obj: &ingressroutev1.IngressRoute{ ObjectMeta: metav1.ObjectMeta{ @@ -637,6 +661,18 @@ func TestKubernetesCacheInsert(t *testing.T) { }, want: false, }, + "insert ingressroute incorrect projectcontour.io/ingress.class": { + obj: &ingressroutev1.IngressRoute{ + ObjectMeta: metav1.ObjectMeta{ + Name: "simple", + Namespace: "default", + Annotations: map[string]string{ + "projectcontour.io/ingress.class": "nginx", + }, + }, + }, + want: false, + }, "insert ingressroute: explicit contour.heptio.com/ingress.class": { obj: &ingressroutev1.IngressRoute{ ObjectMeta: metav1.ObjectMeta{ @@ -661,6 +697,18 @@ func TestKubernetesCacheInsert(t *testing.T) { }, want: true, }, + "insert ingressroute explicit projectcontour.io/ingress.class": { + obj: &ingressroutev1.IngressRoute{ + ObjectMeta: metav1.ObjectMeta{ + Name: "kuard", + Namespace: "default", + Annotations: map[string]string{ + "projectcontour.io/ingress.class": annotation.DEFAULT_INGRESS_CLASS, + }, + }, + }, + want: true, + }, "insert httpproxy empty ingress annotation": { obj: &projcontour.HTTPProxy{ ObjectMeta: metav1.ObjectMeta{ @@ -694,6 +742,18 @@ func TestKubernetesCacheInsert(t *testing.T) { }, want: false, }, + "insert httpproxy incorrect projectcontour.io/ingress.class": { + obj: &projcontour.HTTPProxy{ + ObjectMeta: metav1.ObjectMeta{ + Name: "simple", + Namespace: "default", + Annotations: map[string]string{ + "projectcontour.io/ingress.class": "nginx", + }, + }, + }, + want: false, + }, "insert httpproxy: explicit contour.heptio.com/ingress.class": { obj: &projcontour.HTTPProxy{ ObjectMeta: metav1.ObjectMeta{ @@ -718,6 +778,18 @@ func TestKubernetesCacheInsert(t *testing.T) { }, want: true, }, + "insert httpproxy explicit projectcontour.io/ingress.class": { + obj: &projcontour.HTTPProxy{ + ObjectMeta: metav1.ObjectMeta{ + Name: "kuard", + Namespace: "default", + Annotations: map[string]string{ + "projectcontours.io/ingress.class": annotation.DEFAULT_INGRESS_CLASS, + }, + }, + }, + want: true, + }, "insert tls contour/v1beta1.certificate delegation": { obj: &ingressroutev1.TLSCertificateDelegation{ ObjectMeta: metav1.ObjectMeta{