Check for missing errors in GraphQlTester#executeAndVerify
Prior to this commit, the `GraphQlTester#executeAndVerify` method would check that an `"$.errors"` JSON path exists within the response and contains no value. This should fail with valid GraphQL responses, as the spec says that a response with no error should not contain the errors map at all: http://spec.graphql.org/draft/#sec-Errors This commit changes the assertion and instead checks for the absence of the errors map in the response. Fixes gh-318
This commit is contained in:
@@ -170,7 +170,7 @@ final class DefaultGraphQlTester implements GraphQlTester {
|
||||
|
||||
@Override
|
||||
public void executeAndVerify() {
|
||||
execute().path("$.errors").valueIsEmpty();
|
||||
execute().path("$.errors").pathDoesNotExist();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -186,6 +186,17 @@ public class GraphQlTesterTests extends GraphQlTesterTestSupport {
|
||||
assertThat(input.getVariables()).containsEntry("keyOnly", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
void errorsEmptyOnExecuteAndVerify() {
|
||||
|
||||
String document = "{me {name, friends}}";
|
||||
setMockResponse("{\"me\": {\"name\":\"Luke Skywalker\", \"friends\":[]}}");
|
||||
|
||||
graphQlTester().document(document).executeAndVerify();
|
||||
|
||||
assertThat(requestInput().getDocument()).contains(document);
|
||||
}
|
||||
|
||||
@Test
|
||||
void errorsCheckedOnExecuteAndVerify() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user