diff options
Diffstat (limited to 'example/formJsonPost')
-rw-r--r-- | example/formJsonPost/app/src/FormJsonPost.scala | 2 | ||||
-rw-r--r-- | example/formJsonPost/app/test/src/ExampleTests.scala | 18 | ||||
-rw-r--r-- | example/formJsonPost/build.sc | 2 |
3 files changed, 11 insertions, 11 deletions
diff --git a/example/formJsonPost/app/src/FormJsonPost.scala b/example/formJsonPost/app/src/FormJsonPost.scala index 3714f39..b994ac1 100644 --- a/example/formJsonPost/app/src/FormJsonPost.scala +++ b/example/formJsonPost/app/src/FormJsonPost.scala @@ -1,7 +1,7 @@ package app object FormJsonPost extends cask.MainRoutes{ @cask.postJson("/json") - def jsonEndpoint(value1: ujson.Js.Value, value2: Seq[Int]) = { + def jsonEndpoint(value1: ujson.Value, value2: Seq[Int]) = { "OK " + value1 + " " + value2 } diff --git a/example/formJsonPost/app/test/src/ExampleTests.scala b/example/formJsonPost/app/test/src/ExampleTests.scala index 148ebfd..4178497 100644 --- a/example/formJsonPost/app/test/src/ExampleTests.scala +++ b/example/formJsonPost/app/test/src/ExampleTests.scala @@ -4,7 +4,7 @@ import io.undertow.Undertow import utest._ object ExampleTests extends TestSuite{ - def test[T](example: cask.main.BaseMain)(f: String => T): T = { + def withServer[T](example: cask.main.BaseMain)(f: String => T): T = { val server = Undertow.builder .addHttpListener(8080, "localhost") .setHandler(example.defaultHandler) @@ -17,23 +17,23 @@ object ExampleTests extends TestSuite{ } val tests = Tests{ - 'FormJsonPost - test(FormJsonPost){ host => - requests.post(s"$host/json", data = """{"value1": true, "value2": [3]}""").text() ==> - "OK true List(3)" + test("FormJsonPost") - withServer(FormJsonPost){ host => + val response1 = requests.post(s"$host/json", data = """{"value1": true, "value2": [3]}""") + ujson.read(response1.text()) ==> ujson.Str("OK true List(3)") - requests.post( + val response2 = requests.post( s"$host/form", data = Seq("value1" -> "hello", "value2" -> "1", "value2" -> "2") - ).text() ==> - "OK FormValue(hello,null) List(1, 2)" + ) + response2.text() ==> "OK FormValue(hello,null) List(1, 2)" - val resp = requests.post( + val response3 = requests.post( s"$host/upload", data = requests.MultiPart( requests.MultiItem("image", "...", "my-best-image.txt") ) ) - resp.text() ==> "my-best-image.txt" + response3.text() ==> "my-best-image.txt" } } } diff --git a/example/formJsonPost/build.sc b/example/formJsonPost/build.sc index c0e75a7..e4c2108 100644 --- a/example/formJsonPost/build.sc +++ b/example/formJsonPost/build.sc @@ -9,7 +9,7 @@ trait AppModule extends ScalaModule{ def testFrameworks = Seq("utest.runner.Framework") def ivyDeps = Agg( - ivy"com.lihaoyi::utest::0.6.9", + ivy"com.lihaoyi::utest::0.7.1", ivy"com.lihaoyi::requests::0.2.0", ) } |