Correction des tests

This commit is contained in:
FyloZ 2021-05-28 19:21:23 -04:00
parent feabcc5b76
commit e0a472f1a2
2 changed files with 13 additions and 1 deletions

View File

@ -42,6 +42,12 @@ data class ConfigurationEntity(
override fun equals(other: Any?) =
other is ConfigurationEntity && key == other.key && content == other.content
override fun hashCode(): Int {
var result = key.hashCode()
result = 31 * result + content.hashCode()
return result
}
}
data class ConfigurationDto(

View File

@ -1,7 +1,10 @@
package dev.fyloz.colorrecipesexplorer.service.files
import dev.fyloz.colorrecipesexplorer.config.properties.CreProperties
import dev.fyloz.colorrecipesexplorer.model.ConfigurationType
import dev.fyloz.colorrecipesexplorer.model.configuration
import dev.fyloz.colorrecipesexplorer.repository.TouchUpKitRepository
import dev.fyloz.colorrecipesexplorer.service.ConfigurationService
import dev.fyloz.colorrecipesexplorer.service.touchupkit.TOUCH_UP_TEXT_EN
import dev.fyloz.colorrecipesexplorer.service.touchupkit.TOUCH_UP_TEXT_FR
import dev.fyloz.colorrecipesexplorer.service.touchupkit.TouchUpKitServiceImpl
@ -21,7 +24,8 @@ private class TouchUpKitServiceTestContext {
val creProperties = mockk<CreProperties> {
every { cacheGeneratedFiles } returns false
}
val touchUpKitService = spyk(TouchUpKitServiceImpl(fileService, mockk(), touchUpKitRepository))
val configService = mockk<ConfigurationService>(relaxed = true)
val touchUpKitService = spyk(TouchUpKitServiceImpl(fileService, configService, touchUpKitRepository))
val pdfDocumentData = mockk<ByteArrayResource>()
val pdfDocument = mockk<PdfDocument> {
mockkStatic(PdfDocument::toByteArrayResource)
@ -81,6 +85,7 @@ class TouchUpKitServiceTest {
every { creProperties.cacheGeneratedFiles } returns true
every { fileService.exists(any()) } returns true
every { fileService.read(any()) } returns pdfDocumentData
every { configService.get(ConfigurationType.TOUCH_UP_KIT_CACHE_PDF) } returns configuration(ConfigurationType.TOUCH_UP_KIT_CACHE_PDF, "true")
val redResource = touchUpKitService.generateJobPdfResource(job)
@ -109,6 +114,7 @@ class TouchUpKitServiceTest {
fun `cachePdfDocument() writes the given document to the FileService when cache is enabled`() {
test {
every { creProperties.cacheGeneratedFiles } returns true
every { configService.get(ConfigurationType.TOUCH_UP_KIT_CACHE_PDF) } returns configuration(ConfigurationType.TOUCH_UP_KIT_CACHE_PDF, "true")
with(touchUpKitService) {
job.cachePdfDocument(pdfDocument)