Add tests for Find functions
This commit is contained in:
172
src/integration-test/kotlin/postgresql/FindIT.kt
Normal file
172
src/integration-test/kotlin/postgresql/FindIT.kt
Normal file
@@ -0,0 +1,172 @@
|
||||
package solutions.bitbadger.documents.postgresql
|
||||
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import solutions.bitbadger.documents.common.Find
|
||||
import kotlin.test.Test
|
||||
|
||||
/**
|
||||
* PostgreSQL integration tests for the `Find` object / `find*` connection extension functions
|
||||
*/
|
||||
@DisplayName("PostgreSQL - Find")
|
||||
class FindIT {
|
||||
|
||||
@Test
|
||||
@DisplayName("all retrieves all documents")
|
||||
fun allDefault() =
|
||||
PgDB().use(Find::allDefault)
|
||||
|
||||
@Test
|
||||
@DisplayName("all sorts data ascending")
|
||||
fun allAscending() =
|
||||
PgDB().use(Find::allAscending)
|
||||
|
||||
@Test
|
||||
@DisplayName("all sorts data descending")
|
||||
fun allDescending() =
|
||||
PgDB().use(Find::allDescending)
|
||||
|
||||
@Test
|
||||
@DisplayName("all sorts data numerically")
|
||||
fun allNumOrder() =
|
||||
PgDB().use(Find::allNumOrder)
|
||||
|
||||
@Test
|
||||
@DisplayName("all succeeds with an empty table")
|
||||
fun allEmpty() =
|
||||
PgDB().use(Find::allEmpty)
|
||||
|
||||
@Test
|
||||
@DisplayName("byId retrieves a document via a string ID")
|
||||
fun byIdString() =
|
||||
PgDB().use(Find::byIdString)
|
||||
|
||||
@Test
|
||||
@DisplayName("byId retrieves a document via a numeric ID")
|
||||
fun byIdNumber() =
|
||||
PgDB().use(Find::byIdNumber)
|
||||
|
||||
@Test
|
||||
@DisplayName("byId returns null when a matching ID is not found")
|
||||
fun byIdNotFound() =
|
||||
PgDB().use(Find::byIdNotFound)
|
||||
|
||||
@Test
|
||||
@DisplayName("byFields retrieves matching documents")
|
||||
fun byFieldsMatch() =
|
||||
PgDB().use(Find::byFieldsMatch)
|
||||
|
||||
@Test
|
||||
@DisplayName("byFields retrieves ordered matching documents")
|
||||
fun byFieldsMatchOrdered() =
|
||||
PgDB().use(Find::byFieldsMatchOrdered)
|
||||
|
||||
@Test
|
||||
@DisplayName("byFields retrieves matching documents with a numeric IN clause")
|
||||
fun byFieldsMatchNumIn() =
|
||||
PgDB().use(Find::byFieldsMatchNumIn)
|
||||
|
||||
@Test
|
||||
@DisplayName("byFields succeeds when no documents match")
|
||||
fun byFieldsNoMatch() =
|
||||
PgDB().use(Find::byFieldsNoMatch)
|
||||
|
||||
@Test
|
||||
@DisplayName("byFields retrieves matching documents with an IN_ARRAY comparison")
|
||||
fun byFieldsMatchInArray() =
|
||||
PgDB().use(Find::byFieldsMatchInArray)
|
||||
|
||||
@Test
|
||||
@DisplayName("byFields succeeds when no documents match an IN_ARRAY comparison")
|
||||
fun byFieldsNoMatchInArray() =
|
||||
PgDB().use(Find::byFieldsNoMatchInArray)
|
||||
|
||||
@Test
|
||||
@DisplayName("byContains retrieves matching documents")
|
||||
fun byContainsMatch() =
|
||||
PgDB().use(Find::byContainsMatch)
|
||||
|
||||
@Test
|
||||
@DisplayName("byContains retrieves ordered matching documents")
|
||||
fun byContainsMatchOrdered() =
|
||||
PgDB().use(Find::byContainsMatchOrdered)
|
||||
|
||||
@Test
|
||||
@DisplayName("byContains succeeds when no documents match")
|
||||
fun byContainsNoMatch() =
|
||||
PgDB().use(Find::byContainsNoMatch)
|
||||
|
||||
@Test
|
||||
@DisplayName("byJsonPath retrieves matching documents")
|
||||
fun byJsonPathMatch() =
|
||||
PgDB().use(Find::byJsonPathMatch)
|
||||
|
||||
@Test
|
||||
@DisplayName("byJsonPath retrieves ordered matching documents")
|
||||
fun byJsonPathMatchOrdered() =
|
||||
PgDB().use(Find::byJsonPathMatchOrdered)
|
||||
|
||||
@Test
|
||||
@DisplayName("byJsonPath succeeds when no documents match")
|
||||
fun byJsonPathNoMatch() =
|
||||
PgDB().use(Find::byJsonPathNoMatch)
|
||||
|
||||
@Test
|
||||
@DisplayName("firstByFields retrieves a matching document")
|
||||
fun firstByFieldsMatchOne() =
|
||||
PgDB().use(Find::firstByFieldsMatchOne)
|
||||
|
||||
@Test
|
||||
@DisplayName("firstByFields retrieves a matching document among many")
|
||||
fun firstByFieldsMatchMany() =
|
||||
PgDB().use(Find::firstByFieldsMatchMany)
|
||||
|
||||
@Test
|
||||
@DisplayName("firstByFields retrieves a matching document among many (ordered)")
|
||||
fun firstByFieldsMatchOrdered() =
|
||||
PgDB().use(Find::firstByFieldsMatchOrdered)
|
||||
|
||||
@Test
|
||||
@DisplayName("firstByFields returns null when no document matches")
|
||||
fun firstByFieldsNoMatch() =
|
||||
PgDB().use(Find::firstByFieldsNoMatch)
|
||||
|
||||
@Test
|
||||
@DisplayName("firstByContains retrieves a matching document")
|
||||
fun firstByContainsMatchOne() =
|
||||
PgDB().use(Find::firstByContainsMatchOne)
|
||||
|
||||
@Test
|
||||
@DisplayName("firstByContains retrieves a matching document among many")
|
||||
fun firstByContainsMatchMany() =
|
||||
PgDB().use(Find::firstByContainsMatchMany)
|
||||
|
||||
@Test
|
||||
@DisplayName("firstByContains retrieves a matching document among many (ordered)")
|
||||
fun firstByContainsMatchOrdered() =
|
||||
PgDB().use(Find::firstByContainsMatchOrdered)
|
||||
|
||||
@Test
|
||||
@DisplayName("firstByContains returns null when no document matches")
|
||||
fun firstByContainsNoMatch() =
|
||||
PgDB().use(Find::firstByContainsNoMatch)
|
||||
|
||||
@Test
|
||||
@DisplayName("firstByJsonPath retrieves a matching document")
|
||||
fun firstByJsonPathMatchOne() =
|
||||
PgDB().use(Find::firstByJsonPathMatchOne)
|
||||
|
||||
@Test
|
||||
@DisplayName("firstByJsonPath retrieves a matching document among many")
|
||||
fun firstByJsonPathMatchMany() =
|
||||
PgDB().use(Find::firstByJsonPathMatchMany)
|
||||
|
||||
@Test
|
||||
@DisplayName("firstByJsonPath retrieves a matching document among many (ordered)")
|
||||
fun firstByJsonPathMatchOrdered() =
|
||||
PgDB().use(Find::firstByJsonPathMatchOrdered)
|
||||
|
||||
@Test
|
||||
@DisplayName("firstByJsonPath returns null when no document matches")
|
||||
fun firstByJsonPathNoMatch() =
|
||||
PgDB().use(Find::firstByJsonPathNoMatch)
|
||||
}
|
||||
Reference in New Issue
Block a user