mirror of
https://github.com/SOR2171/Ktor_Server_Demo.git
synced 2026-10-24 02:51:10 +08:00
This commit is contained in:
@@ -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())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user