Skip to content

Commit

Permalink
add missing projectcontour.io/ingress.class annotation tests (project…
Browse files Browse the repository at this point in the history
…contour#2536)

Signed-off-by: Steve Sloka <slokas@vmware.com>
  • Loading branch information
stevesloka authored May 19, 2020
1 parent b5cb729 commit f4d0d23
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
24 changes: 24 additions & 0 deletions internal/annotation/annotations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand Down
72 changes: 72 additions & 0 deletions internal/dag/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand Down Expand Up @@ -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{
Expand All @@ -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{
Expand Down Expand Up @@ -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{
Expand All @@ -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{
Expand Down

0 comments on commit f4d0d23

Please sign in to comment.