@@ -265,3 +265,76 @@ func TestIntegrationAndPipeSameTraits(t *testing.T) {
265
265
require .NoError (t , err )
266
266
assert .True (t , result )
267
267
}
268
+
269
+ func TestMergePlatformTraits (t * testing.T ) {
270
+ integration := & v1.Integration {
271
+ Spec : v1.IntegrationSpec {
272
+ Traits : v1.Traits {
273
+ Camel : & traitv1.CamelTrait {
274
+ Properties : []string {"hello=world" },
275
+ },
276
+ },
277
+ },
278
+ }
279
+ platform := & v1.IntegrationPlatform {
280
+ Status : v1.IntegrationPlatformStatus {
281
+ IntegrationPlatformSpec : v1.IntegrationPlatformSpec {
282
+ Traits : v1.Traits {
283
+ Camel : & traitv1.CamelTrait {
284
+ RuntimeVersion : "1.2.3" ,
285
+ },
286
+ },
287
+ },
288
+ },
289
+ }
290
+
291
+ expectedOptions := Options {
292
+ "camel" : {
293
+ "properties" : []any {"hello=world" },
294
+ "runtimeVersion" : "1.2.3" ,
295
+ },
296
+ }
297
+
298
+ c , err := internal .NewFakeClient ()
299
+ require .NoError (t , err )
300
+ mergedOptions , err := NewSpecTraitsOptionsForIntegrationAndPlatform (c , integration , platform )
301
+ require .NoError (t , err )
302
+ assert .Equal (t , expectedOptions , mergedOptions )
303
+ }
304
+
305
+ func TestMergePlatformTraitsIntegrationPriority (t * testing.T ) {
306
+ integration := & v1.Integration {
307
+ Spec : v1.IntegrationSpec {
308
+ Traits : v1.Traits {
309
+ Camel : & traitv1.CamelTrait {
310
+ Properties : []string {"hello=world" },
311
+ RuntimeVersion : "0.0.0" ,
312
+ },
313
+ },
314
+ },
315
+ }
316
+ platform := & v1.IntegrationPlatform {
317
+ Status : v1.IntegrationPlatformStatus {
318
+ IntegrationPlatformSpec : v1.IntegrationPlatformSpec {
319
+ Traits : v1.Traits {
320
+ Camel : & traitv1.CamelTrait {
321
+ RuntimeVersion : "1.2.3" ,
322
+ },
323
+ },
324
+ },
325
+ },
326
+ }
327
+
328
+ expectedOptions := Options {
329
+ "camel" : {
330
+ "properties" : []any {"hello=world" },
331
+ "runtimeVersion" : "0.0.0" ,
332
+ },
333
+ }
334
+
335
+ c , err := internal .NewFakeClient ()
336
+ require .NoError (t , err )
337
+ mergedOptions , err := NewSpecTraitsOptionsForIntegrationAndPlatform (c , integration , platform )
338
+ require .NoError (t , err )
339
+ assert .Equal (t , expectedOptions , mergedOptions )
340
+ }
0 commit comments