@@ -31,10 +31,6 @@ import (
31
31
"k8s.io/apimachinery/pkg/runtime"
32
32
"k8s.io/apimachinery/pkg/runtime/schema"
33
33
clientgotesting "k8s.io/client-go/testing"
34
- v1 "knative.dev/eventing/pkg/apis/duck/v1"
35
- "knative.dev/eventing/pkg/apis/eventing"
36
- fakeeventingclient "knative.dev/eventing/pkg/client/injection/client/fake"
37
- "knative.dev/eventing/pkg/reconciler/source/duck/resources"
38
34
"knative.dev/pkg/apis"
39
35
duckv1 "knative.dev/pkg/apis/duck/v1"
40
36
"knative.dev/pkg/client/injection/ducks/duck/v1/source"
@@ -43,8 +39,14 @@ import (
43
39
logtesting "knative.dev/pkg/logging/testing"
44
40
"knative.dev/pkg/ptr"
45
41
46
- . "knative.dev/eventing/pkg/reconciler/testing/v1beta2"
42
+ v1 "knative.dev/eventing/pkg/apis/duck/v1"
43
+ "knative.dev/eventing/pkg/apis/eventing"
44
+ fakeeventingclient "knative.dev/eventing/pkg/client/injection/client/fake"
45
+ "knative.dev/eventing/pkg/reconciler/source/duck/resources"
46
+
47
47
. "knative.dev/pkg/reconciler/testing"
48
+
49
+ . "knative.dev/eventing/pkg/reconciler/testing/v1beta2"
48
50
)
49
51
50
52
const (
@@ -250,6 +252,50 @@ func TestAllCases(t *testing.T) {
250
252
WantCreates : []runtime.Object {
251
253
makeEventType ("my-type-1" , "http://my-source-1" ),
252
254
},
255
+ }, {
256
+ Name : "no op" ,
257
+ Objects : []runtime.Object {
258
+ makeSource ([]duckv1.CloudEventAttributes {{
259
+ Type : "my-type-1" ,
260
+ Source : "http://my-source-1" ,
261
+ }}),
262
+ func () runtime.Object {
263
+ s := makeSourceCRD ([]eventTypeEntry {{
264
+ Type : "my-type-1" ,
265
+ Schema : "/some-schema-from-crd" ,
266
+ Description : "This came from the annotation in a crd for the source." ,
267
+ }})
268
+ s .Annotations [eventing .EventTypesAnnotationKey ] = "something that is not valid json"
269
+ return s
270
+ }(),
271
+ makeEventType ("my-type-1" , "http://my-source-1" ),
272
+ },
273
+ Key : testNS + "/" + sourceName ,
274
+ WantCreates : []runtime.Object {},
275
+ }, {
276
+ Name : "no op with namespace" ,
277
+ Objects : []runtime.Object {
278
+ makeSource ([]duckv1.CloudEventAttributes {{
279
+ Type : "my-type-1" ,
280
+ Source : "http://my-source-1" ,
281
+ }}),
282
+ func () runtime.Object {
283
+ s := makeSourceCRD ([]eventTypeEntry {{
284
+ Type : "my-type-1" ,
285
+ Schema : "/some-schema-from-crd" ,
286
+ Description : "This came from the annotation in a crd for the source." ,
287
+ }})
288
+ s .Annotations [eventing .EventTypesAnnotationKey ] = "something that is not valid json"
289
+ return s
290
+ }(),
291
+ func () runtime.Object {
292
+ et := makeEventType ("my-type-1" , "http://my-source-1" )
293
+ et .Spec .Reference .Namespace = testNS
294
+ return et
295
+ }(),
296
+ },
297
+ Key : testNS + "/" + sourceName ,
298
+ WantCreates : []runtime.Object {},
253
299
}}
254
300
255
301
logger := logtesting .TestLogger (t )
@@ -340,14 +386,11 @@ func makeSourceCRD(eventTypes []eventTypeEntry) *apix1.CustomResourceDefinition
340
386
}
341
387
342
388
func makeEventType (ceType , ceSource string ) * v1beta2.EventType {
343
- return makeEventTypeWithReference (ceType , ceSource , brokerDest .Ref )
389
+ return makeEventTypeWithReference (ceType , ceSource , brokerDest .Ref . DeepCopy () )
344
390
}
345
391
346
392
func makeEventTypeWithReference (ceType , ceSource string , ref * duckv1.KReference ) * v1beta2.EventType {
347
393
ceSourceURL , _ := apis .ParseURL (ceSource )
348
- if ref .Namespace == "" {
349
- ref .Namespace = "default"
350
- }
351
394
return & v1beta2.EventType {
352
395
ObjectMeta : metav1.ObjectMeta {
353
396
Name : fmt .Sprintf ("%x" , md5 .Sum ([]byte (ceType + ceSource + sourceUID ))),
0 commit comments