Skip to content

Commit

Permalink
Use jdbcRunnableSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejbak85 committed Jan 8, 2021
1 parent 3e6e4d8 commit 9653d3a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
17 changes: 3 additions & 14 deletions jdbc/src/main/scala/zio/sql/JdbcRunnableSpec.scala
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
package zio.sql

import zio.{ ZEnv, ZLayer }
import zio.duration._
import zio.test._
import zio.test.environment.TestEnvironment
import zio.test.DefaultRunnableSpec

trait JdbcRunnableSpec extends AbstractRunnableSpec with Jdbc {
trait JdbcRunnableSpec extends DefaultRunnableSpec with Jdbc {

override type Environment = TestEnvironment
type JdbcEnvironment = TestEnvironment
with ReadExecutor
with UpdateExecutor
with DeleteExecutor
with TransactionExecutor
override type Failure = Any

override def aspects: List[TestAspect[Nothing, TestEnvironment, Nothing, Any]] =
List(TestAspect.timeoutWarning(60.seconds))

def jdbcTestEnvironment: ZLayer[ZEnv, Nothing, Environment]

override def runner: TestRunner[Environment, Any] =
TestRunner(TestExecutor.default(ZEnv.live >>> jdbcTestEnvironment))

}
4 changes: 2 additions & 2 deletions mysql/src/test/scala/zio/sql/mysql/MysqlRunnableSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import zio.sql._
import zio.test.environment.TestEnvironment
import zio.test._

trait MysqlRunnableSpec extends DefaultRunnableSpec with Jdbc with MysqlModule {
trait MysqlRunnableSpec extends JdbcRunnableSpec with MysqlModule {

private def connProperties(user: String, password: String): Properties = {
val props = new Properties
Expand All @@ -33,6 +33,6 @@ trait MysqlRunnableSpec extends DefaultRunnableSpec with Jdbc with MysqlModule {

override def spec: Spec[TestEnvironment, TestFailure[Any], TestSuccess] = specLayered.provideCustomLayerShared(layer)

def specLayered: Spec[TestEnvironment with TransactionExecutor with ReadExecutor, TestFailure[Object], TestSuccess]
def specLayered: Spec[JdbcEnvironment, TestFailure[Object], TestSuccess]

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import zio.sql.TestContainer
import zio.Has
import zio.ZLayer
import zio.blocking.Blocking
import zio.sql.Jdbc
import zio.sql.JdbcRunnableSpec

trait PostgresRunnableSpec extends DefaultRunnableSpec with Jdbc with PostgresModule {
trait PostgresRunnableSpec extends JdbcRunnableSpec with PostgresModule {

private def connProperties(user: String, password: String): Properties = {
val props = new Properties
Expand All @@ -34,7 +34,6 @@ trait PostgresRunnableSpec extends DefaultRunnableSpec with Jdbc with PostgresMo

override def spec: Spec[TestEnvironment, TestFailure[Any], TestSuccess] = specLayered.provideCustomLayerShared(layer)

//TODO use object Environment from jdbcrunnable
def specLayered: Spec[TestEnvironment with TransactionExecutor with ReadExecutor, TestFailure[Object], TestSuccess]
def specLayered: Spec[JdbcEnvironment, TestFailure[Object], TestSuccess]

}

0 comments on commit 9653d3a

Please sign in to comment.