Skip to content
Permalink
Browse files

Add configuration for MySQL and PostgreSQL tests on Travis CI.

Using consistent capitalization of table names in PlainSQLTest because
of broken case-sensitivity of MySQL on Linux.
  • Loading branch information
szeiger committed Feb 10, 2014
1 parent a347e32 commit 2a541741915d6917940a8c8747d1270f92c85e6d
@@ -1,7 +1,10 @@
language: scala
script: sbt test
script: sbt -Dslick.testkit.dbprops=test-dbs/databases.travis.properties test
jdk:
- openjdk6
- openjdk6
notifications:
flowdock:
secure: j3YP9TjiIcMRy2mvunF1AHBOFnz2H7mZAFVbHPBNkAjMCwSdBNvLpn33qv6ybr02c5snBDJTs0P70RJ/mh3YsqwnIeloQD9HUfnndKQD6ujxx1QWRI/lVDW4pfVRQEuPsXdW/3AiqxrSG5BS4thiyc3vj3LpnodHwNMUT+Nlmq0=
services:
- mysql
- postgresql
@@ -14,7 +14,7 @@ class PlainSQLTest extends TestkitTest[JdbcTestDB] {

def testSimple = ifCap(TestDB.plainSql) {
def getUsers(id: Option[Int]) = {
val q = Q[User] + "select id, name from users "
val q = Q[User] + "select id, name from USERS "
id map { q + "where id =" +? _ } getOrElse q
}

@@ -23,9 +23,9 @@ class PlainSQLTest extends TestkitTest[JdbcTestDB] {
val createTable = Q[Int] + "create table USERS(ID int not null primary key, NAME varchar(255))"
val populateUsers = List(InsertUser(1, "szeiger"), InsertUser(0, "admin"), InsertUser(2, "guest"), InsertUser(3, "foo"))

val allIDs = Q[Int] + "select id from users"
val userForID = Q[Int, User] + "select id, name from users where id = ?"
val userForIdAndName = Q[(Int, String), User] + "select id, name from users where id = ? and name = ?"
val allIDs = Q[Int] + "select id from USERS"
val userForID = Q[Int, User] + "select id, name from USERS where id = ?"
val userForIdAndName = Q[(Int, String), User] + "select id, name from USERS where id = ? and name = ?"

sharedSession.withTransaction {
println("Creating user table: "+createTable.first)
@@ -93,25 +93,25 @@ class PlainSQLTest extends TestkitTest[JdbcTestDB] {
}

def testInterpolation = ifCap(TestDB.plainSql) {
def userForID(id: Int) = sql"select id, name from users where id = $id".as[User]
def userForIdAndName(id: Int, name: String) = sql"select id, name from users where id = $id and name = $name".as[User]
def userForID(id: Int) = sql"select id, name from USERS where id = $id".as[User]
def userForIdAndName(id: Int, name: String) = sql"select id, name from USERS where id = $id and name = $name".as[User]

sqlu"create table USERS(ID int not null primary key, NAME varchar(255))".execute
val total = (for {
(id, name) <- List((1, "szeiger"), (0, "admin"), (2, "guest"), (3, "foo"))
} yield sqlu"insert into USERS values ($id, $name)".first).sum
assertEquals(4, total)

assertEquals(Set(0,1,2,3), sql"select id from users".as[Int].buildColl[Set])
assertEquals(Set(0,1,2,3), sql"select id from USERS".as[Int].buildColl[Set])

val res = userForID(2).first
println("User for ID 2: "+res)
assertEquals(User(2,"guest"), res)

val s1 = sql"select id from users where name = ${"szeiger"}".as[Int]
val s2 = sql"select id from users where name = '#${"guest"}'".as[Int]
assertEquals("select id from users where name = ?", s1.getStatement)
assertEquals("select id from users where name = 'guest'", s2.getStatement)
val s1 = sql"select id from USERS where name = ${"szeiger"}".as[Int]
val s2 = sql"select id from USERS where name = '#${"guest"}'".as[Int]
assertEquals("select id from USERS where name = ?", s1.getStatement)
assertEquals("select id from USERS where name = 'guest'", s2.getStatement)
assertEquals(List(1), s1.list)
assertEquals(List(2), s2.list)

@@ -0,0 +1,22 @@
# Test database configuration for Travis CI build

postgres.enabled = true
postgres.url = jdbc:postgresql:[DB]
postgres.user = postgres
postgres.password =
postgres.adminDB = postgres
postgres.testDB = slick-test
postgres.create = CREATE DATABASE "[DB]" TEMPLATE = template0
postgres.postCreate = create extension lo
postgres.drop = DROP DATABASE IF EXISTS "[DB]"
postgres.driver = org.postgresql.Driver

mysql.enabled = true
mysql.url = jdbc:mysql://127.0.0.1/[DB]
mysql.user = travis
mysql.password =
mysql.adminDB = mysql
mysql.testDB = scala_query_test
mysql.create = CREATE DATABASE [DB]
mysql.drop = DROP DATABASE IF EXISTS [DB]
mysql.driver = com.mysql.jdbc.Driver

0 comments on commit 2a54174

Please sign in to comment.
You can’t perform that action at this time.