- server config outsourced

- test integrated
This commit is contained in:
stefan
2025-04-18 15:15:42 +02:00
parent 44cef36d00
commit b999cb5832
7 changed files with 150 additions and 13 deletions
@@ -1,15 +1,27 @@
package at.mocode
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
import io.ktor.server.testing.* // Wichtig für testApplication
import kotlin.test.* // Wichtig für assertEquals, assertTrue etc.
class ApplicationTest {
@Test
fun main() {
}
@Test
fun module() {
fun testRootRoute() = testApplication {
application {
module() // Ruft deine Konfigurationsfunktion auf
}
// Sendet eine GET-Anfrage an "/" innerhalb der Test-App
val response = client.get("/")
// Überprüfungen (Assertions)
assertEquals(HttpStatusCode.OK, response.status, "Status Code should be OK")
val content = response.bodyAsText() // Holt den HTML-Body als Text
assertTrue(content.contains("Ktor: Hello, Java 21.0.6!"), "Welcome message missing")
}
}