128 lines
3.9 KiB
Kotlin
128 lines
3.9 KiB
Kotlin
package solutions.bitbadger.documents.kotlinx.tests.integration
|
|
|
|
import org.junit.jupiter.api.DisplayName
|
|
import org.junit.jupiter.api.assertThrows
|
|
import solutions.bitbadger.documents.DocumentException
|
|
import kotlin.test.Test
|
|
|
|
/**
|
|
* SQLite integration tests for the `Find` object / `find*` connection extension functions
|
|
*/
|
|
@DisplayName("KotlinX | SQLite: Find")
|
|
class SQLiteFindIT {
|
|
|
|
@Test
|
|
@DisplayName("all retrieves all documents")
|
|
fun allDefault() =
|
|
SQLiteDB().use(FindFunctions::allDefault)
|
|
|
|
@Test
|
|
@DisplayName("all sorts data ascending")
|
|
fun allAscending() =
|
|
SQLiteDB().use(FindFunctions::allAscending)
|
|
|
|
@Test
|
|
@DisplayName("all sorts data descending")
|
|
fun allDescending() =
|
|
SQLiteDB().use(FindFunctions::allDescending)
|
|
|
|
@Test
|
|
@DisplayName("all sorts data numerically")
|
|
fun allNumOrder() =
|
|
SQLiteDB().use(FindFunctions::allNumOrder)
|
|
|
|
@Test
|
|
@DisplayName("all succeeds with an empty table")
|
|
fun allEmpty() =
|
|
SQLiteDB().use(FindFunctions::allEmpty)
|
|
|
|
@Test
|
|
@DisplayName("byId retrieves a document via a string ID")
|
|
fun byIdString() =
|
|
SQLiteDB().use(FindFunctions::byIdString)
|
|
|
|
@Test
|
|
@DisplayName("byId retrieves a document via a numeric ID")
|
|
fun byIdNumber() =
|
|
SQLiteDB().use(FindFunctions::byIdNumber)
|
|
|
|
@Test
|
|
@DisplayName("byId returns null when a matching ID is not found")
|
|
fun byIdNotFound() =
|
|
SQLiteDB().use(FindFunctions::byIdNotFound)
|
|
|
|
@Test
|
|
@DisplayName("byFields retrieves matching documents")
|
|
fun byFieldsMatch() =
|
|
SQLiteDB().use(FindFunctions::byFieldsMatch)
|
|
|
|
@Test
|
|
@DisplayName("byFields retrieves ordered matching documents")
|
|
fun byFieldsMatchOrdered() =
|
|
SQLiteDB().use(FindFunctions::byFieldsMatchOrdered)
|
|
|
|
@Test
|
|
@DisplayName("byFields retrieves matching documents with a numeric IN clause")
|
|
fun byFieldsMatchNumIn() =
|
|
SQLiteDB().use(FindFunctions::byFieldsMatchNumIn)
|
|
|
|
@Test
|
|
@DisplayName("byFields succeeds when no documents match")
|
|
fun byFieldsNoMatch() =
|
|
SQLiteDB().use(FindFunctions::byFieldsNoMatch)
|
|
|
|
@Test
|
|
@DisplayName("byFields retrieves matching documents with an IN_ARRAY comparison")
|
|
fun byFieldsMatchInArray() =
|
|
SQLiteDB().use(FindFunctions::byFieldsMatchInArray)
|
|
|
|
@Test
|
|
@DisplayName("byFields succeeds when no documents match an IN_ARRAY comparison")
|
|
fun byFieldsNoMatchInArray() =
|
|
SQLiteDB().use(FindFunctions::byFieldsNoMatchInArray)
|
|
|
|
@Test
|
|
@DisplayName("byContains fails")
|
|
fun byContainsFails() {
|
|
assertThrows<DocumentException> { SQLiteDB().use(FindFunctions::byContainsMatch) }
|
|
}
|
|
|
|
@Test
|
|
@DisplayName("byJsonPath fails")
|
|
fun byJsonPathFails() {
|
|
assertThrows<DocumentException> { SQLiteDB().use(FindFunctions::byJsonPathMatch) }
|
|
}
|
|
|
|
@Test
|
|
@DisplayName("firstByFields retrieves a matching document")
|
|
fun firstByFieldsMatchOne() =
|
|
SQLiteDB().use(FindFunctions::firstByFieldsMatchOne)
|
|
|
|
@Test
|
|
@DisplayName("firstByFields retrieves a matching document among many")
|
|
fun firstByFieldsMatchMany() =
|
|
SQLiteDB().use(FindFunctions::firstByFieldsMatchMany)
|
|
|
|
@Test
|
|
@DisplayName("firstByFields retrieves a matching document among many (ordered)")
|
|
fun firstByFieldsMatchOrdered() =
|
|
SQLiteDB().use(FindFunctions::firstByFieldsMatchOrdered)
|
|
|
|
@Test
|
|
@DisplayName("firstByFields returns null when no document matches")
|
|
fun firstByFieldsNoMatch() =
|
|
SQLiteDB().use(FindFunctions::firstByFieldsNoMatch)
|
|
|
|
@Test
|
|
@DisplayName("firstByContains fails")
|
|
fun firstByContainsFails() {
|
|
assertThrows<DocumentException> { SQLiteDB().use(FindFunctions::firstByContainsMatchOne) }
|
|
}
|
|
|
|
@Test
|
|
@DisplayName("firstByJsonPath fails")
|
|
fun firstByJsonPathFails() {
|
|
assertThrows<DocumentException> { SQLiteDB().use(FindFunctions::firstByJsonPathMatchOne) }
|
|
}
|
|
}
|