Skip to content

Add examples of mill + cask + scalasql #4924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions example/scalalib/web/10-todo-webapp-cask-scalasql/build.mill
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package build

import mill._, scalalib._

object `package` extends RootModule with ScalaModule {
def scalaVersion = "2.13.8"

override def ivyDeps = Agg(
ivy"com.lihaoyi::cask:0.9.1",
ivy"com.lihaoyi::scalatags:0.13.1",
ivy"com.lihaoyi::upickle:3.1.0",
ivy"com.lihaoyi::scalasql:0.1.19",
ivy"com.h2database:h2:2.2.224"
)

object test extends ScalaTests {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have one test suite using H2 in memory and one integration suite using PostgreSQL via testcontainers.

def testFramework = "utest.runner.Framework"

override def ivyDeps = Agg(
ivy"com.lihaoyi::utest:0.8.5",
ivy"com.lihaoyi::requests:0.6.9",
ivy"com.dimafeng::testcontainers-scala-postgresql:0.43.0",
ivy"com.dimafeng::testcontainers-scala-scalatest:0.43.0",
ivy"org.testcontainers:postgresql:1.19.1"
)
}
}

// This example demonstrates how to set up a simple Scala webserver
// implementing the popular Todo-MVC demo application. It uses the
// Cask web framework to handle HTTP requests and Scalasql to interact
// with an in-memory H2 database. It includes a test suite
// that spins up the web server locally, creates a postgres testcontainer
// and makes HTTP requests against it.

/** Usage
*
* > ./mill test
* + webapp.WebAppTests.simpleRequest...
*
* > ./mill runBackground
*
* > curl http://localhost:8080
* ...What needs to be done...
* ...
*
* > ./mill clean runBackground
*
*/
Loading
Loading