summaryrefslogtreecommitdiff
path: root/cask/test/src/test
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-07-28 20:35:51 +0800
committerLi Haoyi <haoyi.sg@gmail.com>2018-07-28 21:03:15 +0800
commit229ab52fe36c0882bac8aa84ae484a12d339242a (patch)
treee9f8f5de1309cec044b6eb8c83f3fc5a86e5beda /cask/test/src/test
parent8b14cd206e008b4001f9b257f48870c8d40e8498 (diff)
downloadcask-229ab52fe36c0882bac8aa84ae484a12d339242a.tar.gz
cask-229ab52fe36c0882bac8aa84ae484a12d339242a.tar.bz2
cask-229ab52fe36c0882bac8aa84ae484a12d339242a.zip
wip more readme
Diffstat (limited to 'cask/test/src/test')
-rw-r--r--cask/test/src/test/cask/Decorated.scala11
-rw-r--r--cask/test/src/test/cask/FailureTests.scala15
-rw-r--r--cask/test/src/test/cask/FormJsonPost.scala1
3 files changed, 12 insertions, 15 deletions
diff --git a/cask/test/src/test/cask/Decorated.scala b/cask/test/src/test/cask/Decorated.scala
index ed377cf..3925bf1 100644
--- a/cask/test/src/test/cask/Decorated.scala
+++ b/cask/test/src/test/cask/Decorated.scala
@@ -7,10 +7,10 @@ object Decorated extends cask.MainRoutes{
override def toString = "[haoyi]"
}
class loggedIn extends cask.Decorator {
- def getRawParams(ctx: ParamContext) = Right(Map("user" -> new User()))
+ def getRawParams(ctx: ParamContext) = Right(cask.Decor("user" -> new User()))
}
class withExtra extends cask.Decorator {
- def getRawParams(ctx: ParamContext) = Right(Map("extra" -> 31337))
+ def getRawParams(ctx: ParamContext) = Right(cask.Decor("extra" -> 31337))
}
@withExtra()
@@ -32,5 +32,12 @@ object Decorated extends cask.MainRoutes{
world + user + extra
}
+ @withExtra()
+ @loggedIn()
+ @cask.get("/ignore-extra/:world")
+ def ignoreExtra(world: String)(user: User) = {
+ world + user
+ }
+
initialize()
}
diff --git a/cask/test/src/test/cask/FailureTests.scala b/cask/test/src/test/cask/FailureTests.scala
index dd6914a..3ed4249 100644
--- a/cask/test/src/test/cask/FailureTests.scala
+++ b/cask/test/src/test/cask/FailureTests.scala
@@ -5,7 +5,7 @@ import utest._
object FailureTests extends TestSuite {
class myDecorator extends cask.Decorator {
- def getRawParams(ctx: ParamContext) = Right(Map("extra" -> 31337))
+ def getRawParams(ctx: ParamContext) = Right(cask.Decor("extra" -> 31337))
}
val tests = Tests{
@@ -17,17 +17,7 @@ object FailureTests extends TestSuite {
initialize()
}
""").msg ==>
- "Endpoint hello's number of parameter lists (2) doesn't match number of decorators (1)"
-
- utest.compileError("""
- object Decorated extends cask.MainRoutes{
- @myDecorator()
- @cask.get("/hello/:world")
- def hello(world: String)= world
- initialize()
- }
- """).msg ==>
- "Endpoint hello's number of parameter lists (1) doesn't match number of decorators (2)"
+ "Endpoint hello's number of parameter lists (2) cannot be more than the number of decorators (1)"
utest.compileError("""
object Decorated extends cask.MainRoutes{
@@ -51,3 +41,4 @@ object FailureTests extends TestSuite {
}
}
}
+
diff --git a/cask/test/src/test/cask/FormJsonPost.scala b/cask/test/src/test/cask/FormJsonPost.scala
index 9db3d24..05a8761 100644
--- a/cask/test/src/test/cask/FormJsonPost.scala
+++ b/cask/test/src/test/cask/FormJsonPost.scala
@@ -18,4 +18,3 @@ object FormJsonPost extends cask.MainRoutes{
initialize()
}
-