Skip to content

Consider backing OutOrStdout / OutOrStderr with 2 different writers #658

@bamarni

Description

@bamarni

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions