Fix stderr not printing in TestGoGenerateVendoredPackages #206
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this commit, the TestGoGenerateVendoredPackages test failed to print stderr to the terminal as expected. Stderr was not printed because the test expected ExitError.Stderr to be populated. Per documentation ExitError.Stderr is only populated by the Cmd.Output method, which the test does not use. With this commit, the test uses a buffer to record stderr and include it in the failed test message as previously intended.
This issue was discovered because the TestGoGenerateVendoredPackages test expects moq to be available in the PATH. That means that running tests (go test ./...) in this project without first installing moq (go install) results in the TestGoGenerateVendoredPackages test to fail.
Before this commit, the error message looked as follows:
This error message does not include the output from stderr, making it difficult to know why the test is failing.
With this commit, the error message looks as follows: