mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-15 13:29:38 +00:00
improve tests of repos
This commit is contained in:
@@ -1,21 +1,27 @@
|
||||
package dev.inmo.micro_utils.repos.common.tests
|
||||
|
||||
import com.benasher44.uuid.uuid4
|
||||
import dev.inmo.micro_utils.repos.CRUDRepo
|
||||
import dev.inmo.micro_utils.repos.create
|
||||
import dev.inmo.micro_utils.repos.deleteById
|
||||
import korlibs.time.seconds
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.test.*
|
||||
|
||||
abstract class CommonCRUDRepoTests : CommonRepoTests<CRUDRepo<CommonCRUDRepoTests.Registered, String, CommonCRUDRepoTests.New>>() {
|
||||
@Serializable
|
||||
data class New(
|
||||
val data: String
|
||||
)
|
||||
@Serializable
|
||||
data class Registered(
|
||||
val id: String,
|
||||
val data: String
|
||||
)
|
||||
|
||||
open fun creatingWorksProperly() = runTest(timeout = 120.seconds) {
|
||||
@Test
|
||||
fun creatingWorksProperly() = runTest(timeout = 120.seconds) {
|
||||
val crudRepo = repoCreator()
|
||||
val testData = (0 until testSequencesSize).map {
|
||||
("$it-" + uuid4().toString())
|
||||
@@ -53,7 +59,7 @@ abstract class CommonCRUDRepoTests : CommonRepoTests<CRUDRepo<CommonCRUDRepoTest
|
||||
}
|
||||
}
|
||||
@Test
|
||||
open fun removingWorksProperly() = runTest {
|
||||
fun removingWorksProperly() = runTest {
|
||||
val crudRepo = repoCreator()
|
||||
val testData = (0 until testSequencesSize).map {
|
||||
(it.toString() + uuid4().toString())
|
||||
|
@@ -1,13 +1,17 @@
|
||||
package dev.inmo.micro_utils.repos.common.tests
|
||||
|
||||
import com.benasher44.uuid.uuid4
|
||||
import dev.inmo.micro_utils.repos.*
|
||||
import korlibs.time.seconds
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
abstract class CommonKeyValueRepoTests : CommonRepoTests<KeyValueRepo<String, String>>() {
|
||||
open fun creatingWorksProperly() = runTest(timeout = 120.seconds) {
|
||||
@Test
|
||||
fun creatingWorksProperly() = runTest(timeout = 120.seconds) {
|
||||
val repo = repoCreator()
|
||||
val testData = (0 until testSequencesSize).associate {
|
||||
("$it-" + uuid4().toString()) to "$it-" + uuid4().toString()
|
||||
@@ -26,7 +30,8 @@ abstract class CommonKeyValueRepoTests : CommonRepoTests<KeyValueRepo<String, St
|
||||
assertEquals(repo.get(it.key), it.value)
|
||||
}
|
||||
}
|
||||
open fun unsettingWorksProperly() = runTest {
|
||||
@Test
|
||||
fun unsettingWorksProperly() = runTest {
|
||||
val repo = repoCreator()
|
||||
val testData = (0 until testSequencesSize).associate {
|
||||
(it.toString() + uuid4().toString()) to uuid4().toString()
|
||||
|
@@ -1,3 +1,5 @@
|
||||
package dev.inmo.micro_utils.repos.common.tests
|
||||
|
||||
import com.benasher44.uuid.uuid4
|
||||
import dev.inmo.micro_utils.repos.*
|
||||
import korlibs.time.seconds
|
||||
@@ -7,7 +9,8 @@ import kotlinx.coroutines.test.runTest
|
||||
import kotlin.test.*
|
||||
|
||||
abstract class CommonKeyValuesRepoTests : CommonRepoTests<KeyValuesRepo<String, String>>() {
|
||||
open fun creatingWorksProperly() = runTest(timeout = 120.seconds) {
|
||||
@Test
|
||||
fun creatingWorksProperly() = runTest(timeout = 120.seconds) {
|
||||
val repo = repoCreator()
|
||||
val testData = (0 until testSequencesSize).associate {
|
||||
("$it-" + uuid4().toString()) to (0 until 1000).map {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import dev.inmo.micro_utils.repos.CRUDRepo
|
||||
package dev.inmo.micro_utils.repos.common.tests
|
||||
|
||||
abstract class CommonRepoTests<T> {
|
||||
protected open val testSequencesSize = 1000
|
||||
|
Reference in New Issue
Block a user