Repository navigation
Make dead Spock conditions in execution and directive tests run - #4565
Open
costajohnt wants to merge 1 commit into
Open
costajohnt wants to merge 1 commit into
costajohnt wants to merge 1 commit into
Conversation
Spock only treats top-level expressions in then:/expect: blocks as conditions. Checks nested in if/else or for loops were evaluated and discarded, and "!x instanceof GraphQLObjectType" parses as "(!x) instanceof GraphQLObjectType", which is always false. - ExecutionStrategyTest: the non-null scalar feature asserted nothing. Once the checks ran, every row failed: the parameters used the nullable field type instead of the non-null typeInfo the test builds, and completeValue reports the NonNullableFieldWasNullException through the field value future rather than throwing it. The no-error row also expected an exception. Use typeInfo, unwrap the future and assert the exception and error count for each row. - SubscriptionExecutionStrategyTest: the null-propagation event has data [newMessage: null] (newMessage is nullable), not null. Assert it. - DeferWithDataLoaderTest: assert the batch loader call counts. - ValueTraverserTest, SchemaGeneratorDirectiveHelperTest: fix the always-false instanceof guards.
This branch has not been deployed
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.
Several Spock checks in these tests were never evaluated as conditions, so they could not fail. Spock only asserts top-level expressions in
then:/expect:; a comparison insideif/elseis evaluated and discarded, and!x instanceof Yparses as(!x) instanceof Y, which is always false.ExecutionStrategyTest(non-null scalar feature): the wholethen:was an if/else, so it asserted nothing. Made live, all three rows failed, because the test passed the nullable type instead of the non-nulltypeInfoit built,completeValuereports the error through the field value future rather than throwing, and the no-error row expected an exception. The test now usestypeInfo, joins the future, and asserts the exception and error count againsterrorExpected.SubscriptionExecutionStrategyTest:message.data == nullwas inside a closure. The actual payload is[newMessage: null](newMessageis nullable, so the null bubbles up to it), which is now asserted.DeferWithDataLoaderTest: the batch loader counter checks were inside if/else; they now useassertand pass in all three rows.ValueTraverserTest,SchemaGeneratorDirectiveHelperTest:!x instanceof GraphQLObjectTypebecomes!(x instanceof GraphQLObjectType).Test-only change. The five classes pass locally (151 tests). Found while testing a Groovy linter on the repo.