com.lightningkite.lightningdb.TestMongoExceptions.kt Maven / Gradle / Ivy
package com.lightningkite.lightningdb
import com.lightningkite.lightningserver.exceptions.BadRequestException
import com.mongodb.*
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.runBlocking
import org.junit.Test
import kotlin.test.assertFailsWith
class TestMongoExceptions : MongoTest() {
@Test
fun testUniqueError(): Unit = runBlocking {
prepareModels()
val collection =
(db.collection("MongoExceptions_unique") as MongoFieldCollection)
collection.insertOne(IndexingTestModel(email = "[email protected]", account = "asdf"))
assertFailsWith { collection.insertOne(IndexingTestModel(email = "[email protected]", account = "asdf"))!! }
assertFailsWith {
val item = collection.insertOne(IndexingTestModel(email = "[email protected]", account = "asdf"))!!
collection.updateOneById(item._id, modification { it.email assign "[email protected]" })
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy