Skip to content

Commit

Permalink
use chanel to pass error value
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas committed Jan 1, 2025
1 parent 243cf93 commit 145e516
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion utils/tests/test_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ func RunCmdWithOutputs(t *testing.T, executeCmd func() error) (output string, er
newStdout, stdWriter, cleanUp := redirectOutToPipe(t)
defer cleanUp()

errCh := make(chan error, 1)

go func() {
err = executeCmd()
errCh <- executeCmd()
// Closing the temp stdout in order to be able to read it's content.
assert.NoError(t, stdWriter.Close())
}()
Expand All @@ -70,6 +72,9 @@ func RunCmdWithOutputs(t *testing.T, executeCmd func() error) (output string, er
assert.NoError(t, e)
output = string(content)
log.Debug(output)

err = <-errCh

return
}

Expand Down

0 comments on commit 145e516

Please sign in to comment.