Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider backing OutOrStdout / OutOrStderr with 2 different writers #658

Closed
bamarni opened this issue Mar 28, 2018 · 2 comments
Closed

Consider backing OutOrStdout / OutOrStderr with 2 different writers #658

bamarni opened this issue Mar 28, 2018 · 2 comments

Comments

@bamarni
Copy link
Contributor

bamarni commented Mar 28, 2018

After stumbling upon OutOrStdout and OutOrStderr, I thought they'd be great for testing purposes. From my command I would get stdout / stderr writers by calling them and in tests I could just inject some bytes.Buffer to assert on outputs.

However there is a single SetOutput in the Command, which has the following comment : SetOutput sets the destination for usage and error messages. So I assume this refers to stderr.

Would you consider allowing two writers there?

Some others also seem to be bit by this, in kubectl for example they have to pass the 2 writers explicitly (to properly test command outputs I assume) : https://github.com/kubernetes/kubernetes/blob/e00a60283f87db1bd8db0b80bec622353cf88f96/pkg/kubectl/cmd/auth/cani.go#L84

@github-actions
Copy link

This issue is being marked as stale due to a long period of inactivity

@johnSchnake
Copy link
Collaborator

Seems fixed by #822 which added a SetErr and an ErrWriter. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants