You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2021/07/26 08:52:21 UTC

[camel-k] 01/03: Auxiliary function for async getting of cobra command output as a string was added

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 4ad0083bf62766c117577e32d0c4be3c0c67a096
Author: Vladislav Sokolovskii <vs...@redhat.com>
AuthorDate: Fri Jun 25 18:05:38 2021 +0300

    Auxiliary function for async getting of cobra command output as a string was added
---
 e2e/support/test_support.go | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 01a4536..424e492 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -1372,3 +1372,15 @@ func GetOutputString(command *cobra.Command) string {
 
 	return buf.String()
 }
+
+func GetOutputStringAsync(cmd *cobra.Command) func() string {
+	var buffer bytes.Buffer
+	stdout := bufio.NewWriter(&buffer)
+
+	cmd.SetOut(stdout)
+	go cmd.Execute()
+
+	return func() string {
+		return buffer.String()
+	}
+}