Add RepositityTest
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
val ktor_version: String by project
|
val ktor_version: String by project
|
||||||
val kotlin_version: String by project
|
val kotlin_version: String by project
|
||||||
val logback_version: String by project
|
val logback_version: String by project
|
||||||
@@ -16,6 +18,12 @@ application {
|
|||||||
mainClassName = "io.ktor.server.netty.EngineMain"
|
mainClassName = "io.ktor.server.netty.EngineMain"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType<KotlinCompile> {
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "1.8"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ val Module = module {
|
|||||||
functionsDirectory = config.sqlFiles.resolve("functions")
|
functionsDirectory = config.sqlFiles.resolve("functions")
|
||||||
).createRequester() }
|
).createRequester() }
|
||||||
|
|
||||||
// create generic declaration
|
// TODO: create generic declaration
|
||||||
single { ArticleRepository(get()) }
|
single { ArticleRepository(get()) }
|
||||||
single { ConstitutionRepository(get()) }
|
single { ConstitutionRepository(get()) }
|
||||||
|
|
||||||
|
|||||||
40
src/test/kotlin/RepositoryTest.kt
Normal file
40
src/test/kotlin/RepositoryTest.kt
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import fr.dcproject.Module
|
||||||
|
import fr.dcproject.entity.Article
|
||||||
|
import fr.dcproject.entity.Constitution
|
||||||
|
import io.ktor.locations.KtorExperimentalLocationsAPI
|
||||||
|
import io.ktor.util.KtorExperimentalAPI
|
||||||
|
import org.amshove.kluent.`should equal`
|
||||||
|
import org.amshove.kluent.shouldBe
|
||||||
|
import org.junit.jupiter.api.BeforeAll
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.junit.jupiter.api.TestInstance
|
||||||
|
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
|
||||||
|
import org.koin.core.context.startKoin
|
||||||
|
import org.koin.dsl.koinApplication
|
||||||
|
import org.koin.test.KoinTest
|
||||||
|
import org.koin.test.get
|
||||||
|
import fr.dcproject.repository.Article as RepositoryArticle
|
||||||
|
import fr.dcproject.repository.Constitution as RepositoryConstitution
|
||||||
|
|
||||||
|
@KtorExperimentalLocationsAPI
|
||||||
|
@KtorExperimentalAPI
|
||||||
|
@TestInstance(PER_CLASS)
|
||||||
|
class RepositoryTest: KoinTest {
|
||||||
|
@BeforeAll
|
||||||
|
fun beforeAll() {
|
||||||
|
startKoin { modules(Module) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test get repository`() {
|
||||||
|
koinApplication {
|
||||||
|
val repoArticle = get<RepositoryArticle>()
|
||||||
|
(repoArticle is RepositoryArticle) shouldBe true
|
||||||
|
repoArticle.entityName `should equal` Article::class
|
||||||
|
|
||||||
|
val repoConstitution = get<RepositoryConstitution>()
|
||||||
|
(repoConstitution is RepositoryConstitution) shouldBe true
|
||||||
|
repoConstitution.entityName `should equal` Constitution::class
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user