Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.isoron.uhabits.core.io

import org.apache.commons.io.FileUtils
import org.apache.commons.io.IOUtils
import org.isoron.uhabits.core.BaseUnitTest
import org.isoron.uhabits.core.models.Habit
Expand All @@ -30,6 +29,7 @@ import java.io.IOException
import java.nio.file.Files
import java.util.*
import java.util.zip.ZipFile
import kotlin.test.assertEquals
import kotlin.test.assertTrue

class HabitsCSVExporterTest : BaseUnitTest() {
Expand Down Expand Up @@ -112,11 +112,14 @@ class HabitsCSVExporterTest : BaseUnitTest() {
file.deleteOnExit()
copyAssetToFile(assetFilename, file)

assertTrue(
FileUtils.contentEquals(
file,
File(String.format("%s/%s", baseDir.absolutePath, s))
)
)
val fileContent = normalizeLineEndings(file.readText())
val referenceFile = File(String.format("%s/%s", baseDir.absolutePath, s))
val referenceFileContent = normalizeLineEndings(referenceFile.readText())

assertEquals(fileContent, referenceFileContent)
}

private fun normalizeLineEndings(content: String): String {
return content.replace("\r\n", "\n")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,6 @@ class ListHabitsBehaviorTest : BaseUnitTest() {
FileUtils.deleteDirectory(outputDir)
}

@Test
@Throws(Exception::class)
fun testOnExportCSV_fail() {
val outputDir = Files.createTempDirectory("CSV").toFile()
outputDir.setWritable(false)
whenever(dirFinder.getCSVOutputDir()).thenReturn(outputDir)
behavior.onExportCSV()
verify(screen).showMessage(ListHabitsBehavior.Message.COULD_NOT_EXPORT)
assertTrue(outputDir.delete())
}

@Test
fun testOnHabitClick() {
behavior.onClickHabit(habit1)
Expand Down
Loading