summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.li@databricks.com>2019-09-14 16:45:39 +0800
committerLi Haoyi <haoyi.li@databricks.com>2019-09-14 17:40:26 +0800
commit4e853a9d5b9563dbe1909757bf4be4d8e7d2b36a (patch)
tree684863947658d22f91804090c81a68d012b82b6c /example
parent90b6806e5fb91b207f9d8e2da2a58c25928badea (diff)
downloadcask-4e853a9d5b9563dbe1909757bf4be4d8e7d2b36a.tar.gz
cask-4e853a9d5b9563dbe1909757bf4be4d8e7d2b36a.tar.bz2
cask-4e853a9d5b9563dbe1909757bf4be4d8e7d2b36a.zip
.
Diffstat (limited to 'example')
-rw-r--r--example/compress/app/test/src/ExampleTests.scala4
-rw-r--r--example/compress/build.sc2
-rw-r--r--example/compress2/app/test/src/ExampleTests.scala4
-rw-r--r--example/compress2/build.sc2
-rw-r--r--example/compress3/app/test/src/ExampleTests.scala4
-rw-r--r--example/compress3/build.sc2
-rw-r--r--example/cookies/app/test/src/ExampleTests.scala4
-rw-r--r--example/cookies/build.sc2
-rw-r--r--example/decorated/app/src/Decorated.scala4
-rw-r--r--example/decorated/app/test/src/ExampleTests.scala4
-rw-r--r--example/decorated/build.sc2
-rw-r--r--example/decorated2/app/src/Decorated2.scala4
-rw-r--r--example/decorated2/app/test/src/ExampleTests.scala4
-rw-r--r--example/decorated2/build.sc2
-rw-r--r--example/endpoints/app/src/Endpoints.scala3
-rw-r--r--example/endpoints/app/test/src/ExampleTests.scala4
-rw-r--r--example/endpoints/build.sc2
-rw-r--r--example/formJsonPost/app/test/src/ExampleTests.scala18
-rw-r--r--example/formJsonPost/build.sc2
-rw-r--r--example/httpMethods/app/test/src/ExampleTests.scala4
-rw-r--r--example/httpMethods/build.sc2
-rw-r--r--example/minimalApplication/app/test/src/ExampleTests.scala4
-rw-r--r--example/minimalApplication/build.sc2
-rw-r--r--example/minimalApplication2/app/test/src/ExampleTests.scala4
-rw-r--r--example/minimalApplication2/build.sc2
-rw-r--r--example/redirectAbort/app/test/src/ExampleTests.scala4
-rw-r--r--example/redirectAbort/build.sc2
-rw-r--r--example/scalatags/app/test/src/ExampleTests.scala4
-rw-r--r--example/scalatags/build.sc2
-rw-r--r--example/staticFiles/app/test/src/ExampleTests.scala4
-rw-r--r--example/staticFiles/build.sc2
-rw-r--r--example/todo/app/src/TodoServer.scala2
-rw-r--r--example/todo/app/test/src/ExampleTests.scala4
-rw-r--r--example/todo/build.sc2
-rw-r--r--example/todoApi/app/test/src/ExampleTests.scala4
-rw-r--r--example/todoApi/build.sc2
-rw-r--r--example/todoDb/app/src/TodoMvcDb.scala2
-rw-r--r--example/todoDb/app/test/src/ExampleTests.scala4
-rw-r--r--example/todoDb/build.sc2
-rw-r--r--example/twirl/app/test/src/ExampleTests.scala4
-rw-r--r--example/twirl/build.sc2
-rw-r--r--example/variableRoutes/app/test/src/ExampleTests.scala4
-rw-r--r--example/variableRoutes/build.sc2
-rw-r--r--example/websockets/app/test/src/ExampleTests.scala6
-rw-r--r--example/websockets/build.sc2
45 files changed, 76 insertions, 75 deletions
diff --git a/example/compress/app/test/src/ExampleTests.scala b/example/compress/app/test/src/ExampleTests.scala
index 5a4a5bf..cd4d8d0 100644
--- a/example/compress/app/test/src/ExampleTests.scala
+++ b/example/compress/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,7 +17,7 @@ object ExampleTests extends TestSuite{
}
val tests = Tests{
- 'Compress - test(Compress){ host =>
+ test("Compress") - withServer(Compress){ host =>
val expected = "Hello World! Hello World! Hello World!"
requests.get(s"$host").text() ==> expected
assert(
diff --git a/example/compress/build.sc b/example/compress/build.sc
index ac96e15..5e00fc0 100644
--- a/example/compress/build.sc
+++ b/example/compress/build.sc
@@ -10,7 +10,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",
)
}
diff --git a/example/compress2/app/test/src/ExampleTests.scala b/example/compress2/app/test/src/ExampleTests.scala
index cbe3301..9f9b4b3 100644
--- a/example/compress2/app/test/src/ExampleTests.scala
+++ b/example/compress2/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,7 +17,7 @@ object ExampleTests extends TestSuite{
}
val tests = Tests{
- 'Compress2Main - test(Compress2Main) { host =>
+ test("Compress2Main") - withServer(Compress2Main) { host =>
val expected = "Hello World! Hello World! Hello World!"
requests.get(s"$host").text() ==> expected
assert(
diff --git a/example/compress2/build.sc b/example/compress2/build.sc
index c0e75a7..e4c2108 100644
--- a/example/compress2/build.sc
+++ b/example/compress2/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",
)
}
diff --git a/example/compress3/app/test/src/ExampleTests.scala b/example/compress3/app/test/src/ExampleTests.scala
index 3b013f8..88e1cbf 100644
--- a/example/compress3/app/test/src/ExampleTests.scala
+++ b/example/compress3/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,7 +17,7 @@ object ExampleTests extends TestSuite{
}
val tests = Tests{
- 'Compress3Main - test(Compress3Main){ host =>
+ test("Compress3Main") - withServer(Compress3Main){ host =>
val expected = "Hello World! Hello World! Hello World!"
requests.get(s"$host").text() ==> expected
assert(
diff --git a/example/compress3/build.sc b/example/compress3/build.sc
index c0e75a7..e4c2108 100644
--- a/example/compress3/build.sc
+++ b/example/compress3/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",
)
}
diff --git a/example/cookies/app/test/src/ExampleTests.scala b/example/cookies/app/test/src/ExampleTests.scala
index 951728b..150f59a 100644
--- a/example/cookies/app/test/src/ExampleTests.scala
+++ b/example/cookies/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,7 +17,7 @@ object ExampleTests extends TestSuite{
}
val tests = Tests{
- 'Cookies - test(Cookies){ host =>
+ test("Cookies") - withServer(Cookies){ host =>
val sess = requests.Session()
sess.get(s"$host/read-cookie").statusCode ==> 400
sess.get(s"$host/store-cookie")
diff --git a/example/cookies/build.sc b/example/cookies/build.sc
index c0e75a7..e4c2108 100644
--- a/example/cookies/build.sc
+++ b/example/cookies/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",
)
}
diff --git a/example/decorated/app/src/Decorated.scala b/example/decorated/app/src/Decorated.scala
index f037c6a..b3f1149 100644
--- a/example/decorated/app/src/Decorated.scala
+++ b/example/decorated/app/src/Decorated.scala
@@ -4,12 +4,12 @@ object Decorated extends cask.MainRoutes{
override def toString = "[haoyi]"
}
class loggedIn extends cask.Decorator {
- def wrapFunction(ctx: cask.Request, delegate: Delegate): Returned = {
+ def wrapFunction(ctx: cask.Request, delegate: Delegate): OuterReturned = {
delegate(Map("user" -> new User()))
}
}
class withExtra extends cask.Decorator {
- def wrapFunction(ctx: cask.Request, delegate: Delegate): Returned = {
+ def wrapFunction(ctx: cask.Request, delegate: Delegate): OuterReturned = {
delegate(Map("extra" -> 31337))
}
}
diff --git a/example/decorated/app/test/src/ExampleTests.scala b/example/decorated/app/test/src/ExampleTests.scala
index 9aea3bc..c2c19a6 100644
--- a/example/decorated/app/test/src/ExampleTests.scala
+++ b/example/decorated/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,7 +17,7 @@ object ExampleTests extends TestSuite{
}
val tests = Tests{
- 'Decorated - test(Decorated){ host =>
+ test("Decorated") - withServer(Decorated){ host =>
requests.get(s"$host/hello/woo").text() ==> "woo31337"
requests.get(s"$host/internal/boo").text() ==> "boo[haoyi]"
requests.get(s"$host/internal-extra/goo").text() ==> "goo[haoyi]31337"
diff --git a/example/decorated/build.sc b/example/decorated/build.sc
index c0e75a7..e4c2108 100644
--- a/example/decorated/build.sc
+++ b/example/decorated/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",
)
}
diff --git a/example/decorated2/app/src/Decorated2.scala b/example/decorated2/app/src/Decorated2.scala
index 20526b7..fa4b1c5 100644
--- a/example/decorated2/app/src/Decorated2.scala
+++ b/example/decorated2/app/src/Decorated2.scala
@@ -4,12 +4,12 @@ object Decorated2 extends cask.MainRoutes{
override def toString = "[haoyi]"
}
class loggedIn extends cask.Decorator {
- def wrapFunction(ctx: cask.Request, delegate: Delegate): Returned = {
+ def wrapFunction(ctx: cask.Request, delegate: Delegate): OuterReturned = {
delegate(Map("user" -> new User()))
}
}
class withExtra extends cask.Decorator {
- def wrapFunction(ctx: cask.Request, delegate: Delegate): Returned = {
+ def wrapFunction(ctx: cask.Request, delegate: Delegate): OuterReturned = {
delegate(Map("extra" -> 31337))
}
}
diff --git a/example/decorated2/app/test/src/ExampleTests.scala b/example/decorated2/app/test/src/ExampleTests.scala
index 7fec82a..4343097 100644
--- a/example/decorated2/app/test/src/ExampleTests.scala
+++ b/example/decorated2/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,7 +17,7 @@ object ExampleTests extends TestSuite{
}
val tests = Tests{
- 'Decorated2 - test(Decorated2){ host =>
+ test("Decorated2") - withServer(Decorated2){ host =>
requests.get(s"$host/hello/woo").text() ==> "woo31337"
requests.get(s"$host/internal-extra/goo").text() ==> "goo[haoyi]31337"
requests.get(s"$host/ignore-extra/boo").text() ==> "boo[haoyi]"
diff --git a/example/decorated2/build.sc b/example/decorated2/build.sc
index c0e75a7..e4c2108 100644
--- a/example/decorated2/build.sc
+++ b/example/decorated2/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",
)
}
diff --git a/example/endpoints/app/src/Endpoints.scala b/example/endpoints/app/src/Endpoints.scala
index b478c80..b934769 100644
--- a/example/endpoints/app/src/Endpoints.scala
+++ b/example/endpoints/app/src/Endpoints.scala
@@ -2,7 +2,8 @@ package app
class custom(val path: String, val methods: Seq[String]) extends cask.Endpoint{
type Output = Int
- def wrapFunction(ctx: cask.Request, delegate: Delegate): Returned = {
+ type InnerReturned = Int
+ def wrapFunction(ctx: cask.Request, delegate: Delegate): OuterReturned = {
delegate(Map()).map{num =>
cask.Response("Echo " + num, statusCode = num)
}
diff --git a/example/endpoints/app/test/src/ExampleTests.scala b/example/endpoints/app/test/src/ExampleTests.scala
index 1302d85..3314f24 100644
--- a/example/endpoints/app/test/src/ExampleTests.scala
+++ b/example/endpoints/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,7 +17,7 @@ object ExampleTests extends TestSuite{
}
val tests = Tests{
- 'Endpoints - test(Endpoints){ host =>
+ test("Endpoints") - withServer(Endpoints){ host =>
requests.get(s"$host/echo/200").text() ==> "Echo 200"
requests.get(s"$host/echo/200").statusCode ==> 200
requests.get(s"$host/echo/400").text() ==> "Echo 400"
diff --git a/example/endpoints/build.sc b/example/endpoints/build.sc
index c0e75a7..e4c2108 100644
--- a/example/endpoints/build.sc
+++ b/example/endpoints/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",
)
}
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",
)
}
diff --git a/example/httpMethods/app/test/src/ExampleTests.scala b/example/httpMethods/app/test/src/ExampleTests.scala
index e14bcf5..30fa87f 100644
--- a/example/httpMethods/app/test/src/ExampleTests.scala
+++ b/example/httpMethods/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,7 +17,7 @@ object ExampleTests extends TestSuite{
}
val tests = Tests{
- 'HttpMethods - test(HttpMethods){ host =>
+ test("HttpMethods") - withServer(HttpMethods){ host =>
requests.post(s"$host/login").text() ==> "do_the_login"
requests.get(s"$host/login").text() ==> "show_the_login_form"
}
diff --git a/example/httpMethods/build.sc b/example/httpMethods/build.sc
index c0e75a7..e4c2108 100644
--- a/example/httpMethods/build.sc
+++ b/example/httpMethods/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",
)
}
diff --git a/example/minimalApplication/app/test/src/ExampleTests.scala b/example/minimalApplication/app/test/src/ExampleTests.scala
index 8c8ecb2..1cda7a6 100644
--- a/example/minimalApplication/app/test/src/ExampleTests.scala
+++ b/example/minimalApplication/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,7 +17,7 @@ object ExampleTests extends TestSuite{
}
val tests = Tests {
- 'MinimalApplication - test(MinimalApplication) { host =>
+ test("MinimalApplication") - withServer(MinimalApplication) { host =>
val success = requests.get(host)
success.text() ==> "Hello World!"
diff --git a/example/minimalApplication/build.sc b/example/minimalApplication/build.sc
index c0e75a7..e4c2108 100644
--- a/example/minimalApplication/build.sc
+++ b/example/minimalApplication/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",
)
}
diff --git a/example/minimalApplication2/app/test/src/ExampleTests.scala b/example/minimalApplication2/app/test/src/ExampleTests.scala
index 0d8f1bc..4e5621c 100644
--- a/example/minimalApplication2/app/test/src/ExampleTests.scala
+++ b/example/minimalApplication2/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,7 +17,7 @@ object ExampleTests extends TestSuite{
}
val tests = Tests{
- 'MinimalApplication2 - test(MinimalMain){ host =>
+ test("MinimalApplication2") - withServer(MinimalMain){ host =>
val success = requests.get(host)
success.text() ==> "Hello World!"
diff --git a/example/minimalApplication2/build.sc b/example/minimalApplication2/build.sc
index c0e75a7..e4c2108 100644
--- a/example/minimalApplication2/build.sc
+++ b/example/minimalApplication2/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",
)
}
diff --git a/example/redirectAbort/app/test/src/ExampleTests.scala b/example/redirectAbort/app/test/src/ExampleTests.scala
index f095517..a4d149f 100644
--- a/example/redirectAbort/app/test/src/ExampleTests.scala
+++ b/example/redirectAbort/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)
@@ -18,7 +18,7 @@ object ExampleTests extends TestSuite{
val tests = Tests{
- 'RedirectAbort - test(RedirectAbort){ host =>
+ test("RedirectAbort") - withServer(RedirectAbort){ host =>
val resp = requests.get(s"$host/")
resp.statusCode ==> 401
resp.history.get.statusCode ==> 301
diff --git a/example/redirectAbort/build.sc b/example/redirectAbort/build.sc
index c0e75a7..e4c2108 100644
--- a/example/redirectAbort/build.sc
+++ b/example/redirectAbort/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",
)
}
diff --git a/example/scalatags/app/test/src/ExampleTests.scala b/example/scalatags/app/test/src/ExampleTests.scala
index 8eccecf..53bc1ea 100644
--- a/example/scalatags/app/test/src/ExampleTests.scala
+++ b/example/scalatags/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,7 +17,7 @@ object ExampleTests extends TestSuite{
}
val tests = Tests {
- 'Scalatags - test(Scalatags) { host =>
+ test("Scalatags") - withServer(Scalatags) { host =>
val body = requests.get(host).text()
assert(
diff --git a/example/scalatags/build.sc b/example/scalatags/build.sc
index 3971d88..e95569a 100644
--- a/example/scalatags/build.sc
+++ b/example/scalatags/build.sc
@@ -11,7 +11,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",
)
}
diff --git a/example/staticFiles/app/test/src/ExampleTests.scala b/example/staticFiles/app/test/src/ExampleTests.scala
index ab67bcf..ebda8a0 100644
--- a/example/staticFiles/app/test/src/ExampleTests.scala
+++ b/example/staticFiles/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)
@@ -18,7 +18,7 @@ object ExampleTests extends TestSuite{
val tests = Tests{
- 'StaticFiles - test(StaticFiles){ host =>
+ test("StaticFiles") - withServer(StaticFiles){ host =>
requests.get(s"$host/static/file/example.txt").text() ==>
"the quick brown fox jumps over the lazy dog"
diff --git a/example/staticFiles/build.sc b/example/staticFiles/build.sc
index d45045d..e0f8519 100644
--- a/example/staticFiles/build.sc
+++ b/example/staticFiles/build.sc
@@ -11,7 +11,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",
)
diff --git a/example/todo/app/src/TodoServer.scala b/example/todo/app/src/TodoServer.scala
index 4adb55c..1a58d09 100644
--- a/example/todo/app/src/TodoServer.scala
+++ b/example/todo/app/src/TodoServer.scala
@@ -17,7 +17,7 @@ object TodoServer extends cask.MainRoutes{
class transactional extends cask.Decorator{
class TransactionFailed(val value: Router.Result.Error) extends Exception
- def wrapFunction(pctx: cask.Request, delegate: Delegate): Returned = {
+ def wrapFunction(pctx: cask.Request, delegate: Delegate): OuterReturned = {
try ctx.transaction(
delegate(Map()) match{
case Router.Result.Success(t) => Router.Result.Success(t)
diff --git a/example/todo/app/test/src/ExampleTests.scala b/example/todo/app/test/src/ExampleTests.scala
index e8ca7eb..e1be23c 100644
--- a/example/todo/app/test/src/ExampleTests.scala
+++ b/example/todo/app/test/src/ExampleTests.scala
@@ -1,7 +1,7 @@
package app
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 = io.undertow.Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
@@ -13,7 +13,7 @@ object ExampleTests extends TestSuite{
res
}
val tests = Tests{
- 'TodoServer - test(TodoServer){ host =>
+ test("TodoServer") - withServer(TodoServer){ host =>
val page = requests.get(host).text()
assert(page.contains("What needs to be done?"))
}
diff --git a/example/todo/build.sc b/example/todo/build.sc
index beeb947..c5d5610 100644
--- a/example/todo/build.sc
+++ b/example/todo/build.sc
@@ -13,7 +13,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",
)
}
diff --git a/example/todoApi/app/test/src/ExampleTests.scala b/example/todoApi/app/test/src/ExampleTests.scala
index 5e9e11a..4e85a8e 100644
--- a/example/todoApi/app/test/src/ExampleTests.scala
+++ b/example/todoApi/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,7 +17,7 @@ object ExampleTests extends TestSuite{
}
val tests = Tests{
- 'TodoMvcApi - test(TodoMvcApi){ host =>
+ test("TodoMvcApi") - withServer(TodoMvcApi){ host =>
requests.get(s"$host/list/all").text() ==>
"""[{"checked":true,"text":"Get started with Cask"},{"checked":false,"text":"Profit!"}]"""
requests.get(s"$host/list/active").text() ==>
diff --git a/example/todoApi/build.sc b/example/todoApi/build.sc
index c0e75a7..e4c2108 100644
--- a/example/todoApi/build.sc
+++ b/example/todoApi/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",
)
}
diff --git a/example/todoDb/app/src/TodoMvcDb.scala b/example/todoDb/app/src/TodoMvcDb.scala
index 7ce3c50..669b2b8 100644
--- a/example/todoDb/app/src/TodoMvcDb.scala
+++ b/example/todoDb/app/src/TodoMvcDb.scala
@@ -16,7 +16,7 @@ object TodoMvcDb extends cask.MainRoutes{
class transactional extends cask.Decorator{
class TransactionFailed(val value: Router.Result.Error) extends Exception
- def wrapFunction(pctx: cask.Request, delegate: Delegate): Returned = {
+ def wrapFunction(pctx: cask.Request, delegate: Delegate): OuterReturned = {
try ctx.transaction(
delegate(Map()) match{
case Router.Result.Success(t) => Router.Result.Success(t)
diff --git a/example/todoDb/app/test/src/ExampleTests.scala b/example/todoDb/app/test/src/ExampleTests.scala
index eccd913..77cbbb3 100644
--- a/example/todoDb/app/test/src/ExampleTests.scala
+++ b/example/todoDb/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,7 +17,7 @@ object ExampleTests extends TestSuite{
}
val tests = Tests{
- 'TodoMvcDb - test(TodoMvcDb){ host =>
+ test("TodoMvcDb") - withServer(TodoMvcDb){ host =>
requests.get(s"$host/list/all").text() ==>
"""[{"id":1,"checked":true,"text":"Get started with Cask"},{"id":2,"checked":false,"text":"Profit!"}]"""
requests.get(s"$host/list/active").text() ==>
diff --git a/example/todoDb/build.sc b/example/todoDb/build.sc
index e2afdfc..589af39 100644
--- a/example/todoDb/build.sc
+++ b/example/todoDb/build.sc
@@ -12,7 +12,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",
)
}
diff --git a/example/twirl/app/test/src/ExampleTests.scala b/example/twirl/app/test/src/ExampleTests.scala
index 815f656..2c445fb 100644
--- a/example/twirl/app/test/src/ExampleTests.scala
+++ b/example/twirl/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,7 +17,7 @@ object ExampleTests extends TestSuite{
}
val tests = Tests {
- 'Twirl - test(Twirl) { host =>
+ test("Twirl") - withServer(Twirl) { host =>
val body = requests.get(host).text()
assert(
diff --git a/example/twirl/build.sc b/example/twirl/build.sc
index 6a59f0d..de9fc20 100644
--- a/example/twirl/build.sc
+++ b/example/twirl/build.sc
@@ -15,7 +15,7 @@ trait AppModule extends ScalaModule with mill.twirllib.TwirlModule{
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",
)
}
diff --git a/example/variableRoutes/app/test/src/ExampleTests.scala b/example/variableRoutes/app/test/src/ExampleTests.scala
index 48455fa..1755dea 100644
--- a/example/variableRoutes/app/test/src/ExampleTests.scala
+++ b/example/variableRoutes/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,7 +17,7 @@ object ExampleTests extends TestSuite{
}
val tests = Tests{
- 'VariableRoutes - test(VariableRoutes){ host =>
+ test("VariableRoutes") - withServer(VariableRoutes){ host =>
val noIndexPage = requests.get(host)
noIndexPage.statusCode ==> 404
diff --git a/example/variableRoutes/build.sc b/example/variableRoutes/build.sc
index c0e75a7..e4c2108 100644
--- a/example/variableRoutes/build.sc
+++ b/example/variableRoutes/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",
)
}
diff --git a/example/websockets/app/test/src/ExampleTests.scala b/example/websockets/app/test/src/ExampleTests.scala
index 896c051..a463824 100644
--- a/example/websockets/app/test/src/ExampleTests.scala
+++ b/example/websockets/app/test/src/ExampleTests.scala
@@ -8,7 +8,7 @@ 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 = io.undertow.Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
@@ -21,7 +21,7 @@ object ExampleTests extends TestSuite{
}
val tests = Tests{
- 'Websockets - test(Websockets){ host =>
+ test("Websockets") - withServer(Websockets){ host =>
@volatile var out = List.empty[String]
val client = org.asynchttpclient.Dsl.asyncHttpClient();
try{
@@ -72,7 +72,7 @@ object ExampleTests extends TestSuite{
}
}
- 'Websockets2000 - test(Websockets){ host =>
+ test("Websockets2000") - withServer(Websockets){ host =>
@volatile var out = List.empty[String]
val closed = new AtomicInteger(0)
val client = org.asynchttpclient.Dsl.asyncHttpClient();
diff --git a/example/websockets/build.sc b/example/websockets/build.sc
index c788216..197e285 100644
--- a/example/websockets/build.sc
+++ b/example/websockets/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",
ivy"org.asynchttpclient:async-http-client:2.5.2"
)