44 lines
1.4 KiB
Scala
44 lines
1.4 KiB
Scala
package solutions.bitbadger.documents.scala.tests.integration
|
|
|
|
import org.junit.jupiter.api.{DisplayName, Test}
|
|
import org.junit.jupiter.api.Assertions.assertThrows
|
|
import solutions.bitbadger.documents.DocumentException
|
|
|
|
import scala.util.Using
|
|
|
|
/**
|
|
* SQLite integration tests for the `Exists` object / `existsBy*` connection extension functions
|
|
*/
|
|
@DisplayName("Scala | SQLite: Exists")
|
|
class SQLiteExistsIT:
|
|
|
|
@Test
|
|
@DisplayName("byId returns true when a document matches the ID")
|
|
def byIdMatch(): Unit =
|
|
Using(SQLiteDB()) { db => ExistsFunctions.byIdMatch(db) }
|
|
|
|
@Test
|
|
@DisplayName("byId returns false when no document matches the ID")
|
|
def byIdNoMatch(): Unit =
|
|
Using(SQLiteDB()) { db => ExistsFunctions.byIdNoMatch(db) }
|
|
|
|
@Test
|
|
@DisplayName("byFields returns true when documents match")
|
|
def byFieldsMatch(): Unit =
|
|
Using(SQLiteDB()) { db => ExistsFunctions.byFieldsMatch(db) }
|
|
|
|
@Test
|
|
@DisplayName("byFields returns false when no documents match")
|
|
def byFieldsNoMatch(): Unit =
|
|
Using(SQLiteDB()) { db => ExistsFunctions.byFieldsNoMatch(db) }
|
|
|
|
@Test
|
|
@DisplayName("byContains fails")
|
|
def byContainsFails(): Unit =
|
|
Using(SQLiteDB()) { db => assertThrows(classOf[DocumentException], () => ExistsFunctions.byContainsMatch(db)) }
|
|
|
|
@Test
|
|
@DisplayName("byJsonPath fails")
|
|
def byJsonPathFails(): Unit =
|
|
Using(SQLiteDB()) { db => assertThrows(classOf[DocumentException], () => ExistsFunctions.byJsonPathMatch(db)) }
|