This commit is contained in:
SOR
2026-10-09 19:42:34 +08:00
parent 2c6198aa1e
commit acea3bf1e4
42 changed files with 1587 additions and 77 deletions
+15 -10
View File
@@ -1,18 +1,23 @@
package io.github.sor2171
import io.ktor.client.request.get
import io.ktor.http.HttpStatusCode
import io.ktor.server.testing.testApplication
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import io.ktor.server.testing.*
import kotlin.test.*
class ServerTest {
@Test
fun `test root endpoint`() = testApplication {
// loads default configuration
configure()
// verify server root returns 200
assertEquals(HttpStatusCode.OK, client.get("/").status)
fun `test basic test route`() = testApplication {
routing {
get("/api/test/hello") {
call.respondText("Hello Kotlin WebFlux!")
}
}
val response = client.get("/api/test/hello")
assertEquals(HttpStatusCode.OK, response.status)
assertEquals("Hello Kotlin WebFlux!", response.bodyAsText())
}
}