This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 60e76628da2494e4672b582c8cf05a452e26e768
Author: Vladislav Sokolovskii <[email protected]>
AuthorDate: Mon Mar 15 14:11:05 2021 +0100

    Auxiliary function for getting output of the kamel cli commands was added
---
 e2e/support/test_support.go | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 93a1e09..d49c63f 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -22,6 +22,7 @@ limitations under the License.
 package support
 
 import (
+       "bytes"
        "bufio"
        "context"
        "encoding/json"
@@ -1311,3 +1312,21 @@ func NewTestNamespace(injectKnativeBroker bool) 
ctrl.Object {
        }
        return obj
 }
+
+func GetOutputString(command *cobra.Command) string {
+       var buf bytes.Buffer
+       reader, writer, err := os.Pipe()
+       if err != nil {
+               panic(err)
+       }
+
+       command.SetOut(writer)
+       command.Execute()
+
+       writer.Close()
+       defer reader.Close()
+
+       buf.ReadFrom(reader)
+
+       return buf.String()
+}

Reply via email to