-
Notifications
You must be signed in to change notification settings - Fork 475
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
goss add command to set default assertions for empty stdout/stderr #820
Comments
Thank you for filing this. There seem to be two parts:
bugThe bug has to do with command:
# the sleep command produces no stdout or stderr
sleep_test:
exec: |
>&2 echo "hi"
exit-status: 0
stderr: [ "!/./" ]
timeout: 10000 See my comment here for more info: #145 (comment) Essentially, the check is if any line is empty.. but there are no lines, so it fails to find an empty line. You can test this behavior with My memory is a bit hazy, but I feel like I explored making a special case for empty output, but it caused a breaking change somewhere.. but I could be wrong. I'll re-evaluate this with fresh eyes and see if it makes sense to special case empty string. feature requestFor the feature request, the upcoming goss v4 #814 provides a way to handle this easier: command:
sleep_test:
exec: |
>&2 echo hi
exit-status: 0
stderr: ""
It will also handle newlines correctly, for example:
The only way the above will pass is with I'll have to reflect a bit about defaults when doing a feedbackWould love your thoughts on the above.. |
Thanks a lot @aelsabbahy for your prompt and detailed answer !
Thanks for the workaround which properly detects empty strings, with the following known limitations
command:
"echo my_stdout > /dev/stdout; echo my_stderr > /dev/stderr":
exit-status: 0
stdout: [ "!/./" ]
stderr: [ "!/./" ]
timeout: 10000
This looks great to me, fully satisfying my needs !
With the v4 behavior for "" matcher, the current default behavior (i.e. adding "" matchers in I'm looking forward to using goss v4 ! |
Forgot to mention, I released a release candidate v0.4.0-rc1 a few days (weeks?) ago. Would love your feedback on it to make sure it correctly covers this need. |
Changed the behavior of `goss add` on a command, if the value of stdout or stderr is empty, it will be defaulted to an empty string instead of an empty array. The behavior remains unchanged when there is output; the value will be an array. This approach provides the following benefits: * Tests will fail if an empty string receives a value. * Arrays allows for simpler deletion of lines that are not relevant to the test assertion. closes #820
v0.4.2 is released with empty strings when there's no output. Feel free to re-open an issue if this is still a problem. Thank you for reporting! |
Describe the feature:
As a goss user,
In order to detect non expected stderr/stdout messages in command output
I need the
goss add command
to set assertions when observed stdout/stderr are emptyFor instance, if a binary is missing from the test environment and stderr includes "command not found", I'd need the stderr assert to fail
Describe the solution you'd like
A way to assert empty stdout/stderr similar to #184
And this syntax should be used by default in goss.yaml when the
goss add command
observes empty stdout/stderrDescribe alternatives you've considered
I tried using rexexp to check empty strings such as:
however goss isn't yet failing this assertion:
The text was updated successfully, but these errors were encountered: