You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2021/08/26 14:30:05 UTC
[camel-k] 02/02: feat(cmd/bind): error-handler unit test
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit d039af51396859e1fd97e15545b762ce4bd8ab24
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Mon Aug 23 15:40:07 2021 +0200
feat(cmd/bind): error-handler unit test
Closes #2494
---
pkg/cmd/bind_test.go | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 76 insertions(+)
diff --git a/pkg/cmd/bind_test.go b/pkg/cmd/bind_test.go
index 8467d31..d5682b4 100644
--- a/pkg/cmd/bind_test.go
+++ b/pkg/cmd/bind_test.go
@@ -82,3 +82,79 @@ func TestBindOutputUnknownFormat(t *testing.T) {
assert.Equal(t, "invalid output format option 'fail', should be one of: yaml|json\n", output)
}
+
+func TestBindErrorHandlerDLCKamelet(t *testing.T) {
+ buildCmdOptions, bindCmd, _ := initializeBindCmdOptions(t)
+ output, err := test.ExecuteCommand(bindCmd, cmdBind, "my:src", "my:dst", "-o", "yaml",
+ "--error-handler", "dlc:my-kamelet", "-p", "error-handler.my-prop=value")
+ assert.Equal(t, "yaml", buildCmdOptions.OutputFormat)
+
+ assert.Nil(t, err)
+ assert.Equal(t, `apiVersion: camel.apache.org/v1alpha1
+kind: KameletBinding
+metadata:
+ creationTimestamp: null
+ name: my-to-my
+spec:
+ errorHandler:
+ dead-letter-channel:
+ endpoint:
+ properties:
+ my-prop: value
+ ref:
+ apiVersion: camel.apache.org/v1alpha1
+ kind: Kamelet
+ name: my-kamelet
+ sink:
+ uri: my:dst
+ source:
+ uri: my:src
+status: {}
+`, output)
+}
+
+func TestBindErrorHandlerNone(t *testing.T) {
+ buildCmdOptions, bindCmd, _ := initializeBindCmdOptions(t)
+ output, err := test.ExecuteCommand(bindCmd, cmdBind, "my:src", "my:dst", "-o", "yaml",
+ "--error-handler", "none")
+ assert.Equal(t, "yaml", buildCmdOptions.OutputFormat)
+
+ assert.Nil(t, err)
+ assert.Equal(t, `apiVersion: camel.apache.org/v1alpha1
+kind: KameletBinding
+metadata:
+ creationTimestamp: null
+ name: my-to-my
+spec:
+ errorHandler:
+ none: null
+ sink:
+ uri: my:dst
+ source:
+ uri: my:src
+status: {}
+`, output)
+}
+
+func TestBindErrorHandlerRef(t *testing.T) {
+ buildCmdOptions, bindCmd, _ := initializeBindCmdOptions(t)
+ output, err := test.ExecuteCommand(bindCmd, cmdBind, "my:src", "my:dst", "-o", "yaml",
+ "--error-handler", "ref:my-registry-reference")
+ assert.Equal(t, "yaml", buildCmdOptions.OutputFormat)
+
+ assert.Nil(t, err)
+ assert.Equal(t, `apiVersion: camel.apache.org/v1alpha1
+kind: KameletBinding
+metadata:
+ creationTimestamp: null
+ name: my-to-my
+spec:
+ errorHandler:
+ ref: my-registry-reference
+ sink:
+ uri: my:dst
+ source:
+ uri: my:src
+status: {}
+`, output)
+}