Skip to content

Commit

Permalink
Merge pull request #505 from a1kemist/slick-pg-updates
Browse files Browse the repository at this point in the history
use testcontainers for tests, update addon/scala versions,
  • Loading branch information
tminglei authored Apr 13, 2021
2 parents f85634f + 6528f18 commit a644b67
Show file tree
Hide file tree
Showing 36 changed files with 219 additions and 159 deletions.
28 changes: 4 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
dist: trusty
sudo: required
services:
- docker
language: scala
scala:
- 2.11.12
- 2.12.12
- 2.13.3
- 2.12.13
- 2.13.5
jdk:
- oraclejdk8
before_install:
- sudo /etc/init.d/postgresql stop
- sudo apt-get -y remove --purge postgresql-9.1
- sudo apt-get -y remove --purge postgresql-9.2
- sudo apt-get -y remove --purge postgresql-9.3
- sudo apt-get -y remove --purge postgresql-9.4
- sudo apt-get -y remove --purge postgresql-9.5
- sudo apt-get -y remove --purge postgresql-9.6
- sudo apt-get -y autoremove
- sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main 10" >> /etc/apt/sources.list.d/postgresql.list'
- wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
- sudo apt-get update
- sudo apt-get -y install postgresql-10 postgresql-contrib-10 postgresql-10-postgis-2.4
- sudo sh -c 'echo "local all postgres trust" > /etc/postgresql/10/main/pg_hba.conf'
- sudo sh -c 'echo -n "host all all 127.0.0.1/32 trust" >> /etc/postgresql/10/main/pg_hba.conf'
- sudo service postgresql restart 10
before_script:
- psql -c 'create database test;' -U postgres
- psql test -c 'CREATE EXTENSION IF NOT EXISTS hstore;' -U postgres
- psql test -c 'CREATE EXTENSION IF NOT EXISTS ltree;' -U postgres
- psql test -c 'CREATE EXTENSION IF NOT EXISTS postgis;' -U postgres
- psql test -c 'CREATE EXTENSION IF NOT EXISTS pg_trgm;' -U postgres
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import java.util.concurrent.Executors

import argonaut.Argonaut._
import argonaut._
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite
import slick.jdbc.{GetResult, PostgresProfile}

import scala.concurrent.{Await, ExecutionContext}
import scala.concurrent.duration._

class PgArgonautSupportSuite extends FunSuite {
class PgArgonautSupportSuite extends AnyFunSuite with PostgresContainer {
implicit val testExecContext = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(4))

trait MyPostgresProfile extends PostgresProfile
Expand All @@ -32,7 +32,7 @@ class PgArgonautSupportSuite extends FunSuite {
///
import MyPostgresProfile.api._

val db = Database.forURL(url = utils.dbUrl, driver = "org.postgresql.Driver")
lazy val db = Database.forURL(url = container.jdbcUrl, driver = "org.postgresql.Driver")

case class JsonBean(id: Long, json: Json)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import java.util.concurrent.Executors
import cats.syntax.either._
import io.circe._
import io.circe.parser._
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite
import slick.jdbc.{GetResult, PostgresProfile}

import scala.concurrent.{Await, ExecutionContext}
import scala.concurrent.duration._

class PgCirceJsonSupportSuite extends FunSuite {
class PgCirceJsonSupportSuite extends AnyFunSuite with PostgresContainer {
implicit val testExecContext = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(4))

trait MyPostgresProfile extends PostgresProfile
Expand All @@ -32,7 +32,7 @@ class PgCirceJsonSupportSuite extends FunSuite {

import MyPostgresProfile.api._

val db = Database.forURL(url = utils.dbUrl, driver = "org.postgresql.Driver")
lazy val db = Database.forURL(url = container.jdbcUrl, driver = "org.postgresql.Driver")

case class JsonBean(id: Long, json: Json)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import java.util.concurrent.Executors
import org.typelevel.jawn._
import org.typelevel.jawn.ast._

import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite
import slick.jdbc.{GetResult, PostgresProfile}

import scala.concurrent.{Await, ExecutionContext}
import scala.concurrent.duration._

class PgJawnJsonSupportSuite extends FunSuite {
class PgJawnJsonSupportSuite extends AnyFunSuite with PostgresContainer {
implicit val testExecContext = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(4))

trait MyPostgresProfile extends PostgresProfile
Expand All @@ -38,7 +38,7 @@ class PgJawnJsonSupportSuite extends FunSuite {
///
import MyPostgresProfile.api._

val db = Database.forURL(url = utils.dbUrl, driver = "org.postgresql.Driver")
lazy val db = Database.forURL(url = container.jdbcUrl, driver = "org.postgresql.Driver")

case class JsonBean(id: Long, json: JValue, jsons: List[JValue])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package com.github.tminglei.slickpg
import java.util.concurrent.Executors

import org.joda.time._
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite
import slick.jdbc.{GetResult, PostgresProfile}

import scala.concurrent.{Await, ExecutionContext}

class PgDateSupportJodaSuite extends FunSuite {
class PgDateSupportJodaSuite extends AnyFunSuite with PostgresContainer {
implicit val testExecContext = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(4))

trait MyPostgresProfile extends PostgresProfile
Expand All @@ -26,7 +26,7 @@ class PgDateSupportJodaSuite extends FunSuite {
///
import MyPostgresProfile.api._

val db = Database.forURL(url = utils.dbUrl, driver = "org.postgresql.Driver")
lazy val db = Database.forURL(url = container.jdbcUrl, driver = "org.postgresql.Driver")

case class DatetimeBean(
id: Long,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package com.github.tminglei.slickpg
import java.util.concurrent.Executors

import org.json4s._
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite
import slick.jdbc.{GetResult, PostgresProfile}

import scala.concurrent.{Await, ExecutionContext}
import scala.concurrent.duration._

class PgJson4sSupportSuite extends FunSuite {
class PgJson4sSupportSuite extends AnyFunSuite with PostgresContainer {
implicit val testExecContext = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(4))

trait MyPostgresProfile extends PostgresProfile
Expand Down Expand Up @@ -40,7 +40,7 @@ class PgJson4sSupportSuite extends FunSuite {
import MyPostgresProfile.api._
import MyPostgresProfile.jsonMethods._

val db = Database.forURL(url = utils.dbUrl, driver = "org.postgresql.Driver")
lazy val db = Database.forURL(url = container.jdbcUrl, driver = "org.postgresql.Driver")

case class JsonBean(id: Long, json: JValue, jsons: List[JValue])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import java.util.concurrent.Executors

import com.vividsolutions.jts.geom.{Geometry, Point}
import com.vividsolutions.jts.io.{WKBWriter, WKTReader, WKTWriter}
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite
import slick.jdbc.{GetResult, PostgresProfile}

import scala.concurrent.{Await, ExecutionContext}
import scala.concurrent.duration._

class PgPostGISSupportSuite extends FunSuite {
class PgPostGISSupportSuite extends AnyFunSuite with PostgresContainer {
implicit val testExecContext = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(4))

trait MyPostgresProfile extends ExPostgresProfile with PgPostGISSupport {
Expand All @@ -27,7 +27,10 @@ class PgPostGISSupportSuite extends FunSuite {
import MyPostgresProfile.api._
import PgGeographyTypes._

val db = Database.forURL(url = utils.dbUrl, driver = "org.postgresql.Driver")
override lazy val imageName: String = "postgis/postgis"
override lazy val imageTag: String = "11-3.0"

lazy val db = Database.forURL(url = container.jdbcUrl, driver = "org.postgresql.Driver")

case class GeometryBean(id: Long, geom: Geometry, geog: Geography)

Expand Down Expand Up @@ -811,9 +814,9 @@ class PgPostGISSupportSuite extends FunSuite {
// ClusterKMeans
PointTests.map(r => (r.id, r.point.clusterKMeans(2) :: Over)).result.map {
r =>
assert(r.find(_._1 == pbean1.id).get._2 == 0)
assert(r.find(_._1 == pbean2.id).get._2 == 1)
assert(r.find(_._1 == pbean3.id).get._2 == 1)
assert(r.find(_._1 == pbean1.id).get._2 == 1)
assert(r.find(_._1 == pbean2.id).get._2 == 0)
assert(r.find(_._1 == pbean3.id).get._2 == 0)
}
)
).andFinally(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import java.util.concurrent.Executors

import org.locationtech.jts.geom.{Geometry, Point}
import org.locationtech.jts.io.{WKBWriter, WKTReader, WKTWriter}
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite
import slick.jdbc.{GetResult, PostgresProfile}

import scala.concurrent.{Await, ExecutionContext}
import scala.concurrent.duration._

class PgPostGISSupportSuite extends FunSuite {
class PgPostGISSupportSuite extends AnyFunSuite with PostgresContainer {
implicit val testExecContext = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(4))

trait MyPostgresProfile extends ExPostgresProfile with PgPostGISSupport {
Expand All @@ -27,7 +27,10 @@ class PgPostGISSupportSuite extends FunSuite {
import MyPostgresProfile.api._
import PgGeographyTypes._

val db = Database.forURL(url = utils.dbUrl, driver = "org.postgresql.Driver")
override lazy val imageName: String = "postgis/postgis"
override lazy val imageTag: String = "11-3.0"

lazy val db = Database.forURL(url = container.jdbcUrl, driver = "org.postgresql.Driver")

case class GeometryBean(id: Long, geom: Geometry, geog: Geography)

Expand Down Expand Up @@ -797,9 +800,9 @@ class PgPostGISSupportSuite extends FunSuite {
// ClusterKMeans
PointTests.map(r => (r.id, r.point.clusterKMeans(2) :: Over)).result.map {
r =>
assert(r.find(_._1 == pbean1.id).get._2 == 0)
assert(r.find(_._1 == pbean2.id).get._2 == 1)
assert(r.find(_._1 == pbean3.id).get._2 == 1)
assert(r.find(_._1 == pbean1.id).get._2 == 1)
assert(r.find(_._1 == pbean2.id).get._2 == 0)
assert(r.find(_._1 == pbean3.id).get._2 == 0)
}
)
).andFinally(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package com.github.tminglei.slickpg
import java.util.concurrent.Executors

import utils.JsonUtils
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite
import play.api.libs.json._
import slick.jdbc.{GetResult, PostgresProfile}

import scala.concurrent.{Await, ExecutionContext}
import scala.concurrent.duration._

class PgPlayJsonSupportSuite extends FunSuite {
class PgPlayJsonSupportSuite extends AnyFunSuite with PostgresContainer {
implicit val testExecContext = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(4))

case class JBean(name: String, count: Int)
Expand Down Expand Up @@ -49,7 +49,7 @@ class PgPlayJsonSupportSuite extends FunSuite {
///
import MyPostgresProfile.api._

val db = Database.forURL(url = utils.dbUrl, driver = "org.postgresql.Driver")
lazy val db = Database.forURL(url = container.jdbcUrl, driver = "org.postgresql.Driver")

case class JsonBean(id: Long, json: JsValue, jsons: List[JsValue], jbean: JBean, jbeans: List[JBean])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package com.github.tminglei.slickpg

import java.util.concurrent.Executors

import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite
import slick.jdbc.{GetResult, PostgresProfile}
import spray.json._

import scala.concurrent.{Await, ExecutionContext}
import scala.concurrent.duration._

class PgSprayJsonSupportSuite extends FunSuite {
class PgSprayJsonSupportSuite extends AnyFunSuite with PostgresContainer {
implicit val testExecContext = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(4))

case class JBean(name: String, count: Int)
Expand Down Expand Up @@ -38,7 +38,7 @@ class PgSprayJsonSupportSuite extends FunSuite {
///
import MyPostgresProfile.api._

val db = Database.forURL(url = utils.dbUrl, driver = "org.postgresql.Driver")
lazy val db = Database.forURL(url = container.jdbcUrl, driver = "org.postgresql.Driver")

case class JsonBean(id: Long, json: JsValue, jbean: JBean)

Expand Down
Loading

0 comments on commit a644b67

Please sign in to comment.