Stream notification log exports
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package se.ajpanton.notificationlog.export
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import se.ajpanton.notificationlog.model.NotificationAction
|
||||
@@ -30,4 +31,24 @@ class LogExporterTest {
|
||||
assertFalse(withoutImage.contains("<img"))
|
||||
assertTrue(withoutImage.contains("[image]"))
|
||||
}
|
||||
|
||||
@Test fun `row writers produce the same export as the convenience methods`() {
|
||||
val settings = LogViewSettings()
|
||||
val csv = listOf(LogExporter.csvHeader(settings), LogExporter.csvRow(imageEntry, settings)).joinToString("\n")
|
||||
val widths = LogExporter.headers(settings).map { it.length }.toMutableList()
|
||||
LogExporter.values(imageEntry, settings).forEachIndexed { index, value ->
|
||||
widths[index] = maxOf(widths[index], value.length)
|
||||
}
|
||||
val formatted = listOf(
|
||||
LogExporter.formattedRow(LogExporter.headers(settings), widths),
|
||||
LogExporter.formattedRow(LogExporter.values(imageEntry, settings), widths),
|
||||
).joinToString("\n")
|
||||
val html = LogExporter.htmlStart(settings) +
|
||||
LogExporter.htmlRow(imageEntry, settings, "images/${imageEntry.imageId}.png") +
|
||||
LogExporter.htmlEnd()
|
||||
|
||||
assertEquals(LogExporter.csv(listOf(imageEntry), settings), csv)
|
||||
assertEquals(LogExporter.formatted(listOf(imageEntry), settings), formatted)
|
||||
assertEquals(LogExporter.html(listOf(imageEntry), settings) { "images/${it.imageId}.png" }, html)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user