squakez commented on a change in pull request #2522:
URL: https://github.com/apache/camel-k/pull/2522#discussion_r675391485



##########
File path: e2e/support/test_support.go
##########
@@ -1110,6 +1110,79 @@ func CreateTimerKamelet(ns string, name string) func() 
error {
        }
 }
 
+func CreateLogKamelet(ns string, name string) func() error {
+       return func() error {
+               kamelet := v1alpha1.Kamelet{
+                       ObjectMeta: metav1.ObjectMeta{
+                               Namespace: ns,
+                               Name:      name,
+                       },
+                       Spec: v1alpha1.KameletSpec{
+                               Definition: &v1alpha1.JSONSchemaProps{
+                                       Properties: 
map[string]v1alpha1.JSONSchemaProp{
+                                               "loggerName": {
+                                                       Type: "string",
+                                               },
+                                       },
+                               },
+                               Flow: asFlow(map[string]interface{}{
+                                       "from": map[string]interface{}{
+                                               "uri": "kamelet:source",
+                                               "steps": 
[]map[string]interface{}{
+                                                       {
+                                                               "to": 
"log:{{loggerName}}",
+                                                       },
+                                               },
+                                       },
+                               }),
+                       },
+               }

Review comment:
       Excellent support method. Better to make it a general function such as 
`CreateKamelet()` and then you use it from another CreateLogKamelet() which is 
local to your test and is in charge to make a specific behavior.

##########
File path: e2e/support/test_support.go
##########
@@ -1110,6 +1110,79 @@ func CreateTimerKamelet(ns string, name string) func() 
error {
        }
 }
 
+func CreateLogKamelet(ns string, name string) func() error {
+       return func() error {
+               kamelet := v1alpha1.Kamelet{
+                       ObjectMeta: metav1.ObjectMeta{
+                               Namespace: ns,
+                               Name:      name,
+                       },
+                       Spec: v1alpha1.KameletSpec{
+                               Definition: &v1alpha1.JSONSchemaProps{
+                                       Properties: 
map[string]v1alpha1.JSONSchemaProp{
+                                               "loggerName": {
+                                                       Type: "string",
+                                               },
+                                       },
+                               },
+                               Flow: asFlow(map[string]interface{}{
+                                       "from": map[string]interface{}{
+                                               "uri": "kamelet:source",
+                                               "steps": 
[]map[string]interface{}{
+                                                       {
+                                                               "to": 
"log:{{loggerName}}",
+                                                       },
+                                               },
+                                       },
+                               }),
+                       },
+               }
+               return TestClient().Create(TestContext, &kamelet)
+       }
+}
+
+func CreateErrorProducerKamelet(ns string, name string) func() error {

Review comment:
       As the other comment, you may have this local to your test extending the 
general `CreateKamelet` func

##########
File path: e2e/support/test_support.go
##########
@@ -1136,6 +1209,28 @@ func BindKameletTo(ns, name, from string, to 
corev1.ObjectReference, properties
        }
 }
 
+func BindKameletToWithErrorHandler(ns, name, from string, to 
corev1.ObjectReference, sourceProperties map[string]string, sinkProperties 
map[string]string, errorHandler map[string]interface{}) func() error {
+       return func() error {
+               kb := v1alpha1.NewKameletBinding(ns, name)
+               kb.Spec = v1alpha1.KameletBindingSpec{
+                               Source: v1alpha1.Endpoint{
+                                       Ref: &corev1.ObjectReference{

Review comment:
       I'd use the same `corev1.ObjectReference` mechanics you're making with 
the `to` input parameters instead, leaving the declaration of the `from` to the 
caller. I think you took it the implementation from `BindKameletTo()` func. 
Check if you can create a func which is returning a general `KameletBinding` 
and the refactor those methods using it. Always good if we can simplify our 
code without adding duplicates.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to