Skip to content

Commit b7c796b

Browse files
author
Arthur Kushka
committed
Added hikary as datasource for slick. Fixed tests execution.
1 parent 686eaaa commit b7c796b

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

build.sbt

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ libraryDependencies ++= {
1717
"org.postgresql" % "postgresql" % "9.4-1201-jdbc41",
1818
"org.flywaydb" % "flyway-core" % "3.2.1",
1919

20+
"com.zaxxer" % "HikariCP" % "2.4.5",
2021
"org.slf4j" % "slf4j-nop" % "1.6.4",
2122

2223
"io.circe" %% "circe-core" % circeV,
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
package me.archdev.restapi.utils
22

3+
import com.zaxxer.hikari.{HikariConfig, HikariDataSource}
4+
35
class DatabaseService(jdbcUrl: String, dbUser: String, dbPassword: String) {
4-
val driver = slick.driver.PostgresDriver
6+
private val hikariConfig = new HikariConfig()
7+
hikariConfig.setJdbcUrl(jdbcUrl)
8+
hikariConfig.setUsername(dbUser)
9+
hikariConfig.setPassword(dbPassword)
510

11+
private val dataSource = new HikariDataSource(hikariConfig)
12+
13+
val driver = slick.driver.PostgresDriver
614
import driver.api._
7-
val db = Database.forURL(jdbcUrl, dbUser, dbPassword, driver = "org.postgresql.Driver")
15+
val db = Database.forDataSource(dataSource)
816
db.createSession()
917
}

src/test/scala/me/archdev/BaseServiceTest.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import scala.util.Random
1515

1616
trait BaseServiceTest extends WordSpec with Matchers with ScalatestRouteTest with CirceSupport {
1717

18+
dbProcess.getProcessId
19+
1820
private val databaseService = new DatabaseService(jdbcUrl, dbUser, dbPassword)
1921

2022
val usersService = new UsersService(databaseService)
@@ -34,6 +36,4 @@ trait BaseServiceTest extends WordSpec with Matchers with ScalatestRouteTest wit
3436
Await.result(Future.sequence(savedTokens), 10.seconds)
3537
}
3638

37-
dbProcess.getProcessId
38-
3939
}

0 commit comments

Comments
 (0)