summaryrefslogtreecommitdiff
path: root/example/formJsonPost/app/test/src/ExampleTests.scala
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2019-09-14 20:44:03 +0800
committerGitHub <noreply@github.com>2019-09-14 20:44:03 +0800
commitdedeed376e1e906ec2eb1574a73f08c24aba47c8 (patch)
tree337f0528e9284759800228e46f649cbc01f5edfe /example/formJsonPost/app/test/src/ExampleTests.scala
parent90b6806e5fb91b207f9d8e2da2a58c25928badea (diff)
parentedd1f62ce364f8b559431249e2350c2bb75fccec (diff)
downloadcask-dedeed376e1e906ec2eb1574a73f08c24aba47c8.tar.gz
cask-dedeed376e1e906ec2eb1574a73f08c24aba47c8.tar.bz2
cask-dedeed376e1e906ec2eb1574a73f08c24aba47c8.zip
Merge pull request #13 from lihaoyi-databricks/wip0.2.3
Upstream some fixes
Diffstat (limited to 'example/formJsonPost/app/test/src/ExampleTests.scala')
-rw-r--r--example/formJsonPost/app/test/src/ExampleTests.scala18
1 files changed, 9 insertions, 9 deletions
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"
}
}
}