-
Notifications
You must be signed in to change notification settings - Fork 255
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
Fix some type checks on the signatures of nested step handlers #647
Conversation
…]string to godog.Steps but they forgot to adjust the type checks. The existing type checks were lax and unable to distinguish []string from godog.Steps but in a couple of places in the code the value is coerced to godog.Steps and so if someone returned []string then the code would blow up. Additionally there were some tests aroudn these types but they also had not been updated but the test was passing for the wrong reason - the particular test expected an error but the cause of the error wasn't the one the code expected.
Go API Changes# github.com/cucumber/godog ## compatible changes Attach: added Attachment: added Attachments: added ErrAmbiguous: added StepAmbiguous: added # github.com/cucumber/godog/formatters ## incompatible changes Formatter.Ambiguous: added # summary Inferred base version: v0.14.1 Suggested version: v0.15.0 |
@mpkorstanje @vearutop - mind taking a look please. The PR description explains it all. |
@@ -179,9 +179,6 @@ func fmtOutputTest(fmtName, testName, featureFilePath string) func(*testing.T) { | |||
expected := normalise(string(expectedOutput)) | |||
actual := normalise(buf.String()) | |||
assert.Equalf(t, expected, actual, "path: %s", expectOutputPath) | |||
if expected != actual { |
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.
I removed some junk
… problem is the function signature and not the args being passed to the function, also added numerous extra assertions on the precise error messages returned. Now that the precise error is being verified in the test I have improved certain error messages to that more accurate detail is included in the errors
The PR looks reasonable but I don't have enough familiarity to review Go. |
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!
🤔 What's changed?
This change fixes some type checks on the signatures and runtime return values of the handlers.
This change also improves the quality of the error messages produced.
--
History ...
At some point someone changed the return type for "nested steps" handlers from []string to godog.Steps but they forgot to adjust the type checks where the handlers are registered.
They got away with this because the existing type checks were lax and unable to distinguish []string from godog.Steps.
However, in a couple of places in the code the value is coerced to godog.Steps and so if someone had actually returned []string then the code would blow up at run time rather than during registration.
Additionally there were some tests around these types but they also had not been updated and the test was passing for the wrong reason - the particular test expected an error but the cause of the error was an accident caused by the coercion mentioned above rather than a delibarate act of the test.
⚡️ What's your motivation?
Bug fix and better error handling.
🏷️ What kind of change is this?
♻️ Anything particular you want feedback on?
I'm pretty sure the change is good - comments please.
📋 Checklist:
This text was originally generated from a template, then edited by hand. You can modify the template here.