Add RepositityTest

This commit is contained in:
2019-08-08 13:40:05 +02:00
parent 86d699c9c0
commit 41b1f75cfb
3 changed files with 49 additions and 1 deletions

View File

@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val ktor_version: String by project
val kotlin_version: String by project
val logback_version: String by project
@@ -16,6 +18,12 @@ application {
mainClassName = "io.ktor.server.netty.EngineMain"
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}
repositories {
mavenLocal()
jcenter()

View File

@@ -22,7 +22,7 @@ val Module = module {
functionsDirectory = config.sqlFiles.resolve("functions")
).createRequester() }
// create generic declaration
// TODO: create generic declaration
single { ArticleRepository(get()) }
single { ConstitutionRepository(get()) }

View 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
}
}
}