File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
main/kotlin/com/uzabase/playtest2/http
test/kotlin/com/uzabase/playtest2/http Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import java.net.http.HttpClient
1010import java.net.http.HttpRequest
1111import java.net.http.HttpRequest.BodyPublishers
1212import java.net.http.HttpResponse.BodyHandlers
13+ import java.nio.file.Files
1314
1415class RequestSteps {
1516
@@ -58,9 +59,13 @@ class RequestSteps {
5859
5960 @Step(" リクエストを送る" )
6061 fun sendRequest () =
61- buildRequest()
62- .let { client.send(it, BodyHandlers .ofString()) }
63- .run { ScenarioDataStore .put(K .RESPONSE , this ) }
62+ Files .createTempFile(" playtest2." , " .tmp" )
63+ .also { it.toFile().deleteOnExit() }
64+ .let { temp ->
65+ buildRequest()
66+ .let { client.send(it, BodyHandlers .ofFile(temp)) }
67+ .run { ScenarioDataStore .put(K .RESPONSE , this ) }
68+ }
6469
6570 private fun buildRequest (): HttpRequest {
6671 @Suppress(" UNCHECKED_CAST" )
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import io.kotest.data.row
1414import io.kotest.matchers.shouldBe
1515import java.net.URI
1616import java.net.http.HttpResponse
17+ import java.nio.file.Path
1718import com.uzabase.playtest2.http.RequestSteps as Sut
1819
1920class RequestStepsTest : FunSpec ({
@@ -45,7 +46,8 @@ class RequestStepsTest : FunSpec({
4546 sut.methodIntoRequest(Sut .Method .GET )
4647 sut.sendRequest()
4748 val response = ScenarioDataStore .get(K .RESPONSE ) as HttpResponse <* >
48- response.body().toString().shouldBe("Hello , world!")
49+ val path = response.body() as Path
50+ path.toFile().readText(Charsets .UTF_8 ).shouldBe("Hello , world!")
4951 }
5052
5153 context("Simple requests") {
You can’t perform that action at this time.
0 commit comments