add tests for cruds

This commit is contained in:
2024-08-09 19:22:32 +06:00
parent 8d86f29325
commit b0569f8421
21 changed files with 585 additions and 9 deletions

View File

@@ -14,5 +14,10 @@ kotlin {
api internalProject("micro_utils.coroutines")
}
}
commonTest {
dependencies {
api project(":micro_utils.repos.common.tests")
}
}
}
}

View File

@@ -0,0 +1,31 @@
package full
import CommonCRUDRepoTests
import com.benasher44.uuid.uuid4
import dev.inmo.micro_utils.repos.CRUDRepo
import dev.inmo.micro_utils.repos.MapCRUDRepo
import kotlinx.coroutines.test.TestResult
import kotlin.test.*
class InMemoryCRUDRepoTests : CommonCRUDRepoTests() {
override val repoCreator: suspend () -> CRUDRepo<Registered, String, New> = {
MapCRUDRepo(
{ new, id, old ->
Registered(id, new.data)
}
) {
val id = uuid4().toString()
id to Registered(id, it.data)
}
}
@Test
override fun creatingWorksProperly(): TestResult {
return super.creatingWorksProperly()
}
@Test
override fun removingWorksProperly(): TestResult {
return super.removingWorksProperly()
}
}

View File

@@ -0,0 +1,20 @@
package full
import CommonKeyValueRepoTests
import dev.inmo.micro_utils.repos.*
import kotlinx.coroutines.test.TestResult
import kotlin.test.*
class InMemoryKeyValueRepoTests : CommonKeyValueRepoTests() {
override val repoCreator: suspend () -> KeyValueRepo<String, String> = { MapKeyValueRepo() }
@Test
override fun creatingWorksProperly(): TestResult {
return super.creatingWorksProperly()
}
@Test
override fun unsettingWorksProperly(): TestResult {
return super.unsettingWorksProperly()
}
}

View File

@@ -0,0 +1,14 @@
package full
import CommonKeyValuesRepoTests
import dev.inmo.micro_utils.repos.*
import kotlinx.coroutines.test.TestResult
import kotlin.test.*
class InMemoryKeyValuesRepoTests : CommonKeyValuesRepoTests() {
override val repoCreator: suspend () -> KeyValuesRepo<String, String> = { MapKeyValuesRepo() }
@Test
override fun creatingWorksProperly(): TestResult {
return super.creatingWorksProperly()
}
}