diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-07-21 23:45:34 +0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-07-21 23:45:45 +0800 |
commit | 1cfe997b4d8874738c2ed384dc221420b42f551b (patch) | |
tree | e090e458bbb1a5ebd66433c67224ac2be20fea4f /cask/test/src/test/cask | |
parent | 3f61791c57b450de84a6599e2338b1afcf172a05 (diff) | |
download | cask-1cfe997b4d8874738c2ed384dc221420b42f551b.tar.gz cask-1cfe997b4d8874738c2ed384dc221420b42f551b.tar.bz2 cask-1cfe997b4d8874738c2ed384dc221420b42f551b.zip |
Static file serving now works
Diffstat (limited to 'cask/test/src/test/cask')
-rw-r--r-- | cask/test/src/test/cask/CaskTest.scala | 48 | ||||
-rw-r--r-- | cask/test/src/test/cask/VariableRoutes.scala | 8 |
2 files changed, 30 insertions, 26 deletions
diff --git a/cask/test/src/test/cask/CaskTest.scala b/cask/test/src/test/cask/CaskTest.scala index 7bbb8de..394e53c 100644 --- a/cask/test/src/test/cask/CaskTest.scala +++ b/cask/test/src/test/cask/CaskTest.scala @@ -7,11 +7,11 @@ object CaskTest extends TestSuite { 'hello - { val x = DispatchTrie.construct(0, - Seq(Vector("hello") -> 1) + Seq((Vector("hello"), 1, false)) ) assert( - x.lookup(List("hello"), Map()) == Some((1, Map())), + x.lookup(List("hello"), Map()) == Some((1, Map(), Nil)), x.lookup(List("hello", "world"), Map()) == None, x.lookup(List("world"), Map()) == None ) @@ -19,13 +19,13 @@ object CaskTest extends TestSuite { 'nested - { val x = DispatchTrie.construct(0, Seq( - Vector("hello", "world") -> 1, - Vector("hello", "cow") -> 2 + (Vector("hello", "world"), 1, false), + (Vector("hello", "cow"), 2, false) ) ) assert( - x.lookup(List("hello", "world"), Map()) == Some((1, Map())), - x.lookup(List("hello", "cow"), Map()) == Some((2, Map())), + x.lookup(List("hello", "world"), Map()) == Some((1, Map(), Nil)), + x.lookup(List("hello", "cow"), Map()) == Some((2, Map(), Nil)), x.lookup(List("hello"), Map()) == None, x.lookup(List("hello", "moo"), Map()) == None, x.lookup(List("hello", "world", "moo"), Map()) == None @@ -33,11 +33,11 @@ object CaskTest extends TestSuite { } 'bindings - { val x = DispatchTrie.construct(0, - Seq(Vector(":hello", ":world") -> 1) + Seq((Vector(":hello", ":world"), 1, false)) ) assert( - x.lookup(List("hello", "world"), Map()) == Some((1, Map("hello" -> "hello", "world" -> "world"))), - x.lookup(List("world", "hello"), Map()) == Some((1, Map("hello" -> "world", "world" -> "hello"))), + x.lookup(List("hello", "world"), Map()) == Some((1, Map("hello" -> "hello", "world" -> "world"), Nil)), + x.lookup(List("world", "hello"), Map()) == Some((1, Map("hello" -> "world", "world" -> "hello"), Nil)), x.lookup(List("hello", "world", "cow"), Map()) == None, x.lookup(List("hello"), Map()) == None @@ -46,12 +46,14 @@ object CaskTest extends TestSuite { 'path - { val x = DispatchTrie.construct(0, - Seq(Vector("hello", "::world") -> 1) + Seq((Vector("hello"), 1, true)) ) + assert( - x.lookup(List("hello", "world"), Map()) == Some((1,Map("world" -> "world"))), - x.lookup(List("hello", "world", "cow"), Map()) == Some((1,Map("world" -> "world/cow"))), - x.lookup(List("hello"), Map()) == None + x.lookup(List("hello", "world"), Map()) == Some((1,Map(), Seq("world"))), + x.lookup(List("hello", "world", "cow"), Map()) == Some((1,Map(), Seq("world", "cow"))), + x.lookup(List("hello"), Map()) == Some((1,Map(), Seq())), + x.lookup(List(), Map()) == None ) } @@ -59,40 +61,40 @@ object CaskTest extends TestSuite { intercept[Exception]{ DispatchTrie.construct(0, Seq( - Vector("hello", ":world") -> 1, - Vector("hello", "world") -> 2 + (Vector("hello", ":world"), 1, false), + (Vector("hello", "world"), 2, false) ) ) } intercept[Exception]{ DispatchTrie.construct(0, Seq( - Vector("hello", ":world") -> 1, - Vector("hello", "world", "omg") -> 2 + (Vector("hello", ":world"), 1, false), + (Vector("hello", "world", "omg"), 2, false) ) ) } intercept[Exception]{ DispatchTrie.construct(0, Seq( - Vector("hello", "::world") -> 1, - Vector("hello", "cow", "omg") -> 2 + (Vector("hello"), 1, true), + (Vector("hello", "cow", "omg"), 2, false) ) ) } intercept[Exception]{ DispatchTrie.construct(0, Seq( - Vector("hello", ":world") -> 1, - Vector("hello", ":cow") -> 2 + (Vector("hello", ":world"), 1, false), + (Vector("hello", ":cow"), 2, false) ) ) } intercept[Exception]{ DispatchTrie.construct(0, Seq( - Vector("hello", "world") -> 1, - Vector("hello", "world") -> 2 + (Vector("hello", "world"), 1, false), + (Vector("hello", "world"), 2, false) ) ) } diff --git a/cask/test/src/test/cask/VariableRoutes.scala b/cask/test/src/test/cask/VariableRoutes.scala index e7415c6..1dda4e6 100644 --- a/cask/test/src/test/cask/VariableRoutes.scala +++ b/cask/test/src/test/cask/VariableRoutes.scala @@ -1,5 +1,7 @@ package test.cask +import cask.Subpath + object VariableRoutes extends cask.MainRoutes{ @cask.get("/user/:userName") def showUserProfile(userName: String) = { @@ -11,9 +13,9 @@ object VariableRoutes extends cask.MainRoutes{ s"Post $postId $query" } - @cask.get("/path/::subPath") - def showSubpath(subPath: String) = { - s"Subpath $subPath" + @cask.get("/path", subpath = true) + def showSubpath(subPath: Subpath) = { + s"Subpath ${subPath.value}" } initialize() |