jdaugherty commented on code in PR #15692:
URL: https://github.com/apache/grails-core/pull/15692#discussion_r3341425046
##########
grails-data-graphql/core/src/test/groovy/org/grails/gorm/graphql/fetcher/impl/DeleteEntityDataFetcherSpec.groovy:
##########
@@ -76,6 +77,19 @@ class DeleteEntityDataFetcherSpec extends HibernateSpec {
1 * responseHandler.createResponse(env, false, _ as
NullPointerException)
}
+ void "test deleteInstance flushes the delete and does not pass the ignored
failOnError argument"() {
+ given:
+ DeleteEntityDataFetcher fetcher = new
DeleteEntityDataFetcher<>(mappingContext.getPersistentEntity(One.name))
+ GormEntity instance = Mock(GormEntity)
+
+ when:
+ fetcher.deleteInstance(instance)
+
+ then: 'the delete is flushed so database failures surface, and
failOnError (ignored by delete) is not used'
+ 1 * instance.delete([flush: true])
+ 0 * instance.delete([failOnError: true])
Review Comment:
Mock tests generally are fragile since we're not actually testing the
result. Shouldn't we instead check the persisted state?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]