From 29b44fe4941bc187187a0e9542cd7fdff2dfdf5a Mon Sep 17 00:00:00 2001 From: Pierangelo Di Pilato Date: Mon, 15 Nov 2021 15:56:22 +0100 Subject: [PATCH] Add test for default deadLetterSink namespace in generic Channel Signed-off-by: Pierangelo Di Pilato --- .../messaging/v1/channel_defaults_test.go | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/pkg/apis/messaging/v1/channel_defaults_test.go b/pkg/apis/messaging/v1/channel_defaults_test.go index c09255f3efe..ed0924cffe6 100644 --- a/pkg/apis/messaging/v1/channel_defaults_test.go +++ b/pkg/apis/messaging/v1/channel_defaults_test.go @@ -22,6 +22,9 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + duckv1 "knative.dev/pkg/apis/duck/v1" + + eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1" "knative.dev/eventing/pkg/apis/messaging/config" "github.com/google/go-cmp/cmp" @@ -89,6 +92,41 @@ func TestChannelSetDefaults(t *testing.T) { }, }, }, + "deadLetterSink.ref.namespace gets defaulted": { + initial: Channel{ + ObjectMeta: metav1.ObjectMeta{ + Name: "imc", + Namespace: "custom", + Annotations: map[string]string{"messaging.knative.dev/subscribable": "v1"}, + }, + Spec: ChannelSpec{ChannelableSpec: eventingduckv1.ChannelableSpec{ + Delivery: &eventingduckv1.DeliverySpec{ + DeadLetterSink: &duckv1.Destination{ + Ref: &duckv1.KReference{ + Name: "foo", + }, + }, + }, + }}, + }, + expected: Channel{ + ObjectMeta: metav1.ObjectMeta{ + Name: "imc", + Namespace: "custom", + Annotations: map[string]string{"messaging.knative.dev/subscribable": "v1"}, + }, + Spec: ChannelSpec{ChannelableSpec: eventingduckv1.ChannelableSpec{ + Delivery: &eventingduckv1.DeliverySpec{ + DeadLetterSink: &duckv1.Destination{ + Ref: &duckv1.KReference{ + Name: "foo", + Namespace: "custom", + }, + }, + }, + }}, + }, + }, } for n, tc := range testCases { t.Run(n, func(t *testing.T) {