Skip to content

Commit

Permalink
test: Hide output in tests
Browse files Browse the repository at this point in the history
Signed-off-by: Sergiy Kulanov <[email protected]>
  • Loading branch information
SergK committed Oct 12, 2023
1 parent f66aa3a commit 5832ed6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/cmd/pipeline/pipeline_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pipeline

import (
"bytes"
"testing"

"github.com/tektoncd/cli/pkg/cli"
Expand All @@ -10,6 +11,10 @@ func TestRoot(t *testing.T) {
// Create a new cobra command.
cmd := Command(&cli.TektonParams{})

// Create a Buffer to capture the output.
out := new(bytes.Buffer)
cmd.SetOut(out)

// Execute the command.
if err := cmd.Execute(); err != nil {
t.Errorf("Failed to execute command: %v", err)
Expand Down
5 changes: 5 additions & 0 deletions pkg/cmd/pipelinerun/pipelinerun_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pipelinerun

import (
"bytes"
"testing"

"github.com/tektoncd/cli/pkg/cli"
Expand All @@ -10,6 +11,10 @@ func TestRoot(t *testing.T) {
// Create a new cobra command.
cmd := Command(&cli.TektonParams{})

// Create a Buffer to capture the output.
out := new(bytes.Buffer)
cmd.SetOut(out)

// Execute the command.
if err := cmd.Execute(); err != nil {
t.Errorf("Failed to execute command: %v", err)
Expand Down
5 changes: 5 additions & 0 deletions pkg/cmd/root_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"bytes"
"testing"

"github.com/tektoncd/cli/pkg/cli"
Expand All @@ -10,6 +11,10 @@ func TestRoot(t *testing.T) {
// Create a new cobra command.
cmd := Root(&cli.TektonParams{})

// Create a Buffer to capture the output.
out := new(bytes.Buffer)
cmd.SetOut(out)

// Execute the command.
if err := cmd.Execute(); err != nil {
t.Errorf("Failed to execute command: %v", err)
Expand Down

0 comments on commit 5832ed6

Please sign in to comment.