diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-08-12 22:18:39 +0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-08-12 22:18:39 +0800 |
commit | fd9c399db8c1c0d86cc65d5e1c41968b42a813d1 (patch) | |
tree | 8e8fc2875cb1c26f309384a9ca0ad72e1fa893f3 /example/todo | |
parent | 9bf8c31fa9321558d7d02f6a5b687cd55a924e7f (diff) | |
download | cask-fd9c399db8c1c0d86cc65d5e1c41968b42a813d1.tar.gz cask-fd9c399db8c1c0d86cc65d5e1c41968b42a813d1.tar.bz2 cask-fd9c399db8c1c0d86cc65d5e1c41968b42a813d1.zip |
auto-upload examples
Diffstat (limited to 'example/todo')
-rw-r--r-- | example/todo/app/resources/todo/app.js (renamed from example/todo/resources/todo/app.js) | 0 | ||||
-rw-r--r-- | example/todo/app/resources/todo/index.css (renamed from example/todo/resources/todo/index.css) | 0 | ||||
-rw-r--r-- | example/todo/app/src/todo/TodoServer.scala (renamed from example/todo/src/todo/Server.scala) | 4 | ||||
-rw-r--r-- | example/todo/app/test/src/todo/TodoTest.scala | 22 | ||||
-rw-r--r-- | example/todo/build.sc | 20 |
5 files changed, 44 insertions, 2 deletions
diff --git a/example/todo/resources/todo/app.js b/example/todo/app/resources/todo/app.js index b7b8437..b7b8437 100644 --- a/example/todo/resources/todo/app.js +++ b/example/todo/app/resources/todo/app.js diff --git a/example/todo/resources/todo/index.css b/example/todo/app/resources/todo/index.css index 208a762..208a762 100644 --- a/example/todo/resources/todo/index.css +++ b/example/todo/app/resources/todo/index.css diff --git a/example/todo/src/todo/Server.scala b/example/todo/app/src/todo/TodoServer.scala index 6f43c6d..0c66895 100644 --- a/example/todo/src/todo/Server.scala +++ b/example/todo/app/src/todo/TodoServer.scala @@ -1,10 +1,10 @@ -package todo +package app import cask.internal.Router import com.typesafe.config.ConfigFactory import io.getquill.{SnakeCase, SqliteJdbcContext} import scalatags.Text.all._ import scalatags.Text.tags2 -object Server extends cask.MainRoutes{ +object TodoServer extends cask.MainRoutes{ val tmpDb = java.nio.file.Files.createTempDirectory("todo-cask-sqlite") object ctx extends SqliteJdbcContext( diff --git a/example/todo/app/test/src/todo/TodoTest.scala b/example/todo/app/test/src/todo/TodoTest.scala new file mode 100644 index 0000000..8f38612 --- /dev/null +++ b/example/todo/app/test/src/todo/TodoTest.scala @@ -0,0 +1,22 @@ +package app +import utest._ +object TodoTests extends TestSuite{ + def test[T](example: cask.main.BaseMain)(f: String => T): T = { + val server = io.undertow.Undertow.builder + .addHttpListener(8080, "localhost") + .setHandler(example.defaultHandler) + .build + server.start() + val res = + try f("http://localhost:8080") + finally server.stop() + res + } + val tests = Tests{ + 'TodoServer - test(TodoServer){ host => + val page = requests.get(host).text() + assert(page.contains("What needs to be done?")) + } + } + +}
\ No newline at end of file diff --git a/example/todo/build.sc b/example/todo/build.sc new file mode 100644 index 0000000..b570b3b --- /dev/null +++ b/example/todo/build.sc @@ -0,0 +1,20 @@ +import mill._, scalalib._ + + +trait AppModule extends ScalaModule{ + def scalaVersion = "2.12.6" + def ivyDeps = Agg( + ivy"com.lihaoyi::cask:0.0.1", + ivy"org.xerial:sqlite-jdbc:3.18.0", + ivy"io.getquill::quill-jdbc:2.5.4" + ) + + object test extends Tests{ + def testFrameworks = Seq("utest.runner.Framework") + def forkArgs = Seq("--illegal-access=deny") + def ivyDeps = Agg( + ivy"com.lihaoyi::utest::0.6.3", + ivy"com.lihaoyi::requests::0.1.2", + ) + } +}
\ No newline at end of file |