Skip to content

Commit

Permalink
resolves #34 Documentation contradicts return type [2]
Browse files Browse the repository at this point in the history
  • Loading branch information
zigzago committed Aug 29, 2017
1 parent 764b597 commit 9f16305
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion kmongo/src/main/kotlin/org/litote/kmongo/extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ fun <T : Any> MongoCollection<T>.updateMany(filter: String, update: String, upda
*
* @return the document that was removed. If no documents matched the query filter, then null will be returned
*/
fun <T> MongoCollection<T>.findOneAndDelete(filter: String, options: FindOneAndDeleteOptions = FindOneAndDeleteOptions()): T
fun <T> MongoCollection<T>.findOneAndDelete(filter: String, options: FindOneAndDeleteOptions = FindOneAndDeleteOptions()): T?
= findOneAndDelete(toBson(filter), options)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.litote.kmongo.issues
import org.junit.Test
import org.litote.kmongo.KMongoBaseTest
import org.litote.kmongo.MongoOperator.set
import org.litote.kmongo.findOneAndDelete
import org.litote.kmongo.findOneAndReplace
import org.litote.kmongo.findOneAndUpdate
import org.litote.kmongo.model.Friend
Expand All @@ -11,16 +12,21 @@ import kotlin.test.assertNull
/**
*
*/
class Issue34FindOneAndUpdateOrReplaceCouldReturnNull : KMongoBaseTest<Friend>() {
class Issue34FindOneAndUpdateOrReplaceOrDeleteCouldReturnNull : KMongoBaseTest<Friend>() {

@Test
fun findOneAndReplaceCouldReturnsNull() {
fun findOneAndReplaceCouldReturnNull() {
assertNull(col.findOneAndReplace("{}", Friend("test")))
}

@Test
fun findOneAndUpdateCouldReturnsNull() {
fun findOneAndUpdateCouldReturnNull() {
assertNull(col.findOneAndUpdate("{}", "{$set:{name:'John'}}"))
}

@Test
fun findOneAndDeleteCouldReturnNull() {
assertNull(col.findOneAndDelete("{}"))
}

}

0 comments on commit 9f16305

Please sign in to comment.