-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Filter out negative line and column error locations in toSpecification #3753
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,7 @@ class GraphQLErrorTest extends Specification { | |
| .description("Test ValidationError") | ||
| .build() | | ||
| [ | ||
| locations: [[line: 666, column: 999], [line: 333, column: 0]], | ||
| locations: [[line: 666, column: 999], [line: 333, column: 1]], | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do these numbers chance - what caused that?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the past, our tests had "0" being used as a valid column location. This PR bans anything less than 1 for line and column number, which made these old tests fail. So I adjusted these old tests to use a valid location number Then added a new test with invalid numbers to check the new filtering behaviour
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The source locations for these old tests are generated by a method lower down in this file |
||
| message : "Test ValidationError", | ||
| extensions:[classification:"ValidationError"], | ||
| ] | ||
|
|
@@ -44,7 +44,7 @@ class GraphQLErrorTest extends Specification { | |
|
|
||
| new InvalidSyntaxError(mkLocations(), "Not good syntax m'kay") | | ||
| [ | ||
| locations: [[line: 666, column: 999], [line: 333, column: 0]], | ||
| locations: [[line: 666, column: 999], [line: 333, column: 1]], | ||
| message : "Not good syntax m'kay", | ||
| extensions:[classification:"InvalidSyntax"], | ||
| ] | ||
|
|
@@ -72,6 +72,28 @@ class GraphQLErrorTest extends Specification { | |
|
|
||
| } | ||
|
|
||
| def "toSpecification filters out error locations with line and column not starting at 1, as required in spec"() { | ||
| // See specification wording: https://spec.graphql.org/draft/#sec-Errors.Error-Result-Format | ||
|
|
||
| given: | ||
| def error = ValidationError.newValidationError() | ||
| .validationErrorType(ValidationErrorType.UnknownType) | ||
| .sourceLocations([mkLocation(-1, -1), mkLocation(333, 1)]) | ||
| .description("Test ValidationError") | ||
| .build() | ||
|
|
||
| def expectedMap = [ | ||
| locations: [ | ||
| [line: 333, column: 1] | ||
| ], | ||
| message: "Test ValidationError", | ||
| extensions: [classification:"ValidationError"] | ||
| ] | ||
|
|
||
| expect: | ||
| error.toSpecification() == expectedMap | ||
| } | ||
|
|
||
| class CustomException extends RuntimeException implements GraphQLError { | ||
| private LinkedHashMap<String, String> map | ||
|
|
||
|
|
@@ -110,7 +132,7 @@ class GraphQLErrorTest extends Specification { | |
| } | ||
|
|
||
| List<SourceLocation> mkLocations() { | ||
| return [mkLocation(666, 999), mkLocation(333, 0)] | ||
| return [mkLocation(666, 999), mkLocation(333, 1)] | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix old tests to be compliant
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh I see |
||
| } | ||
|
|
||
| SourceLocation mkLocation(int line, int column) { | ||
|
|
||
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.
Tiny change, this becomes an immutable map