Add test for default deadLetterSink namespace in generic Channel
@@ -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) {
