test: make stylesheet tests platform-independent

This commit is contained in:
Marc Froehlich committed 2026-10-23 13:21:19 +02:00
1 parent 4642d658a3
commit 936efdd8dd
2 files changed
+11 -7

No files matched your search

@@ -100,11 +100,11 @@ class PaletteStoreFactoryTest(@TempDir private val tempDir: Path) {
val files = OperatorProfilePaletteFiles.of(other) val files = OperatorProfilePaletteFiles.of(other)
assertTrue( assertTrue(
files.dayFile.path.endsWith("profiles/OP2/KST4ContestDefaultDay.css"), files.dayFile.toPath().endsWith(Path.of("profiles", "OP2", "KST4ContestDefaultDay.css")),
"the daylight file is ${files.dayFile.path}", "the daylight file is ${files.dayFile.path}",
) )
assertTrue( assertTrue(
files.eveningFile.path.endsWith("profiles/OP2/KST4ContestDefaultEvening.css"), files.eveningFile.toPath().endsWith(Path.of("profiles", "OP2", "KST4ContestDefaultEvening.css")),
"the evening file is ${files.eveningFile.path}", "the evening file is ${files.eveningFile.path}",
) )
} }
@@ -93,12 +93,16 @@ class StylesheetExportTest {
@Test @Test
fun anUnwritablePlaceIsReportedRatherThanThrown() { fun anUnwritablePlaceIsReportedRatherThanThrown() {
val target = File("/proc/kst4contest-cannot-write-here/day.css") val blockingFile = Files.createTempFile("kst4contest-export-blocked-parent", ".tmp").toFile()
try {
val target = File(blockingFile, "day.css")
val outcome = exportShippedStylesheet(target, darkMode = false)
val outcome = exportShippedStylesheet(target, darkMode = false) assertTrue(outcome is StylesheetExportOutcome.Failed, "outcome was $outcome")
assertNotNull((outcome as StylesheetExportOutcome.Failed).reason)
assertTrue(outcome is StylesheetExportOutcome.Failed, "outcome was $outcome") } finally {
assertNotNull((outcome as StylesheetExportOutcome.Failed).reason) blockingFile.delete()
}
} }
@Test @Test