Implement Mailer

This commit is contained in:
2019-10-08 02:31:23 +02:00
parent c156e2a7b1
commit afb7f7a1a6
7 changed files with 80 additions and 11 deletions

View File

@@ -0,0 +1,28 @@
import fr.dcproject.Env
import fr.dcproject.messages.Mailer
import fr.dcproject.module
import io.ktor.locations.KtorExperimentalLocationsAPI
import io.ktor.server.testing.withTestApplication
import io.ktor.util.KtorExperimentalAPI
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.koin.test.AutoCloseKoinTest
import org.koin.test.KoinTest
import org.koin.test.get
@KtorExperimentalLocationsAPI
@KtorExperimentalAPI
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class MailerTest: KoinTest, AutoCloseKoinTest() {
@Test
fun `can be send an email`() {
withTestApplication({ module(Env.TEST) }) {
get<Mailer>().sendEmail(
"reset-password@dc-project.fr",
"fabrice.lecomte.be@gmail.com",
"Email Work !",
"Test"
)
}
}
}

View File

@@ -1,16 +1,16 @@
import fr.dcproject.Module
import fr.dcproject.Env
import fr.dcproject.entity.Article
import fr.dcproject.entity.Constitution
import fr.dcproject.module
import io.ktor.locations.KtorExperimentalLocationsAPI
import io.ktor.server.testing.withTestApplication
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.AutoCloseKoinTest
import org.koin.test.KoinTest
import org.koin.test.get
import fr.dcproject.repository.Article as RepositoryArticle
@@ -19,15 +19,10 @@ import fr.dcproject.repository.Constitution as RepositoryConstitution
@KtorExperimentalLocationsAPI
@KtorExperimentalAPI
@TestInstance(PER_CLASS)
class RepositoryTest: KoinTest {
@BeforeAll
fun beforeAll() {
startKoin { modules(Module) }
}
class RepositoryTest: KoinTest, AutoCloseKoinTest() {
@Test
fun `test get repository`() {
koinApplication {
withTestApplication({ module(Env.TEST) }) {
val repoArticle = get<RepositoryArticle>()
(repoArticle is RepositoryArticle) shouldBe true
repoArticle.entityName `should equal` Article::class