vector
vector

Reputation: 7576

grails - testing delete()

I just wonder why one method to test delete() works as expected, but another does not? In the following test case:

    def cFound = new Client( ... ).save()

    def cFoundId = cFound.id
    cFound.delete()
    assertEquals 0, Client.count()

... assertEquals 0, Client.count() passes, but ...

    assertFalse Client.exists( cFound.id )
    assertNull Client.get(cFoundId)

... both fail. What could be the underlying reason? Thanks in advance.

Upvotes: 0

Views: 482

Answers (1)

Chris
Chris

Reputation: 8109

Try to flush the context, in order to clean the caches:

cFound.delete(flush: true)

Upvotes: 1

Related Questions