Fix test so it runs on Windows, too
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 27 Sep 2021 09:36:28 +0000 (11:36 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 27 Sep 2021 11:29:27 +0000 (13:29 +0200)
This also means that nobody ever tried to compile Sone on Windows. I
mean, I know that _I_ didn't do it but seeing that apparently nobody
else in the whole wide world has done it kinda makes me sad. Anyway,
it's a simple fix.

src/test/kotlin/net/pterodactylus/sone/web/pages/ReloadingPageTest.kt

index 99cf8bf..30cdc6b 100644 (file)
@@ -8,7 +8,6 @@ import org.hamcrest.Matchers.*
 import org.junit.*
 import org.junit.rules.*
 import java.nio.file.*
-import kotlin.text.Charsets.UTF_8
 
 /**
  * Unit test for [ReloadingPage].
@@ -45,13 +44,14 @@ class ReloadingPageTest {
 
        @Test
        fun `requesting valid file results in 200 and delivers file`() {
-               Files.write(Paths.get(folder.path, "file.txt"), listOf("Hello", "World"), UTF_8)
+               val fileContent = listOf("Hello", "World").joinToString("\n", postfix = "\n")
+               Files.writeString(Paths.get(folder.path, "file.txt"), fileContent)
                webPageTest.request("/prefix/path/file.txt")
                page.handleRequest(freenetRequest, response)
                assertThat(response.statusCode, equalTo(200))
                assertThat(response.statusText, equalTo("OK"))
                assertThat(response.contentType, equalTo("text/plain"))
-               assertThat(responseBytes.toByteArray(), equalTo("Hello\nWorld\n".toByteArray()))
+               assertThat(responseBytes.toByteArray(), equalTo(fileContent.toByteArray()))
        }
 
        @Test