@Test
fun `test save function`(): Unit = runBlocking {
mongoCollection = mockk(relaxed = true)
coEvery { MongoConnection.getCollection<FunctionDO>("functions") } returns mongoCollection
// replaceOne() was called here
mongoFunctionRepo.save(f)
coVerify(exactly = 1){
mongoCollection.replaceOne(
capture(filtersCaptor),
capture(functionDOCaptor),
capture(replaceOptionsCaptor)
)
}
}
}
replaceOne() was called in save()method
override suspend fun save(f: Function) {
MongoConnection.getCollection<FunctionDO>(FUNCTION_TABLE).replaceOne(
Filters.eq(FunctionDO::id.name, f.id.s), f.toMongo(), ReplaceOptions().upsert(true)
)
}
}
I try adding log in replaceOne() method and can comfirmed it was called.
Error information: Verification failed: call 1 of 1: MongoCollection(#1).replaceOne(slotCapture(), slotCapture(), slotCapture(), any())) was not called java.lang.AssertionError: Verification failed: call 1 of 1: MongoCollection(#1).replaceOne(slotCapture(), slotCapture(), slotCapture(), any())) was not called
I noticed that there were four arguments in the error information. Would it be the reason of the problem?