Fix some type checks on the signatures of nested step handlers#647
Merged
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 |
Member
Author
|
@mpkorstanje @vearutop - mind taking a look please. The PR description explains it all. |
Johnlon
commented
Oct 10, 2024
| expected := normalise(string(expectedOutput)) | ||
| actual := normalise(buf.String()) | ||
| assert.Equalf(t, expected, actual, "path: %s", expectOutputPath) | ||
| if expected != actual { |
… 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
Contributor
|
The PR looks reasonable but I don't have enough familiarity to review Go. |
Member
Author
|
thanks folk. I have a bunk of other wip I need finish. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🤔 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.