-
Notifications
You must be signed in to change notification settings - Fork 30
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
Test: Add coverage for Output #149
Conversation
This is awesome for a find, thanks for this! As for your questions: I personally prefer this one: pterm.SetDefaultOutput(os.Stdout)
text{}.DescribeTable(table)
// Output:
// Expected output But given the 3rd part of this, it can definitely make more sense to do the first option if that's easier to implement.
Can we only disable the colors for the tests? I personally don't want to lose the colors for regular output and use of the CLI, perhaps we make an option for disabling colors or a global var that the test can set to disable it?
Should we modify the output to not print trailing whitespaces?
That's fair, we just get a "want: ...." and "got: ...." which would make diffing difficult. In light of this, it might make sense to go with the example you've provided here that writes to a buffer and we compare manually so that we can output the diff instead. |
It's something that
|
@alex-kar oh perfect! I missed that. Nice! |
Also I tried to write something like "parameterized" test to provide different test cases, but not sure if arguments are readable.
But because "metadata json" and "expected output" are quite long multiline strings, it make arguments less readable. @zeroshade WDYT? Is it better to just write separate tests for each case or go with different parameters for the same test? |
@zeroshade Please review tests to cover |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks!
@zeroshade
or
Examples
.testing: examples with trailing whitespace in multiple lines of output can be confusing golang/go#26460
In our case,
Metadata location |
has whitespace after the pipe|
, which is getting removed.And also
Examples
do not provide any diff when actual result doesn't match expected one.So, for this matter I used 3rd party
github.com/MarvinJWendt/testza
, but maybe there is a better approach.I've pushed some working version as an example of what I have so far. I'd appreciate some feedback before I proceed with covering all scenarios.