Hi everyone, I'm working on a API that uses MongoD...
# test
j
Hi everyone, I'm working on a API that uses MongoDB and we are using Morphia as ODM and because of the simplicity of the tool we decide to write a wrapper and a tiny seed system to make our life easier. However we are facing problems in working with partial mocks. We have the following test cases:
Copy code
given("a runSeedsAndConnect call") {

		on("the attempt to create a datastore") {
				val spy = spy(MongoDatabaseConnection())

				it("should return a non null value") {
						val datastore = mongoDatabaseConnection.runSeedsAndConnect()
						datastore.shouldNotBeNull()
				}

				it("should return a Datastore instance") {
						val datastore = mongoDatabaseConnection.runSeedsAndConnect()
						datastore shouldBeInstanceOf Datastore::class
				}

				it("should call createDatastore function") {
						spy.runSeedsAndConnect()
						verify(spy, times(1)).createDatastore()
				}

				it("should call runSeeds function") {
						val datastore = mongoDatabaseConnection.createDatastore()
						spy.runSeedsAndConnect()
						verify(spy, times(2)).runSeeds(datastore)
				}
		}
}
The problem happens int the test
it("should call runSeeds function")
when the
verify(spy, times(2).runSeeds(datastore))
is invoked. For some reason that I don't know I can't call the
verify(...)
function more than once when I'm using a partial mock.