Skip to content

Instantly share code, notes, and snippets.

View afsalthaj's full-sized avatar

Afsal Thaj afsalthaj

View GitHub Profile
import scalaz.concurrent.Task
import scalaz.effect.{IO, LiftIO}
implicit val taskIO: LiftIO[Task] = new LiftIO[Task] {
override def liftIO[A](ioa: IO[A]): Task[A] =
Task.delay(ioa.unsafePerformIO())
}
import au.com.iag.dataeng.retries.instances.TaskInstances
import org.specs2.data.Tag
import org.specs2.matcher.MatchResult
import org.specs2.scalacheck.ScalaCheckFunction1
import org.specs2.specification.core.SpecStructure
import org.specs2.{ ScalaCheck, Specification }
class IntegrationTest extends Specification with ScalaCheck { self =>
// The test requires external environment. In this case
// Take a look at the snippet. This is just a sample. You might have more/less steps as part of docker compose up
object DockerUtil {
lazy val makeDockerFile = taskKey[Seq[ImageName]]("Make a docker image for the app.")
lazy val makeDockerComposeFile = taskKey[File]("Make docker compose file for the project in resource managed location.")
lazy val dockerComposeUp = taskKey[File]("docker-compose up for the project")
def relativeDockerComposePath(resPath: File) = resPath / "docker" / "bin" / "docker-compose.yml"
def settings = Seq(
lazy val myProject =
(project in file("myProject"))
.enablePlugins(DockerPlugin, DockerComposePlugin)
.config(DockerTest)
.settings(inConfig(DockerTest)(Defaults.testTasks): _*)
.settings(testOptions in DockerTest := Seq(Tests.Argument(TestFrameworks.Specs2, "include",
"DockerComposeTag")))
// We exclude in other tests
.settings(testOptions in Test := Seq(
Tests.Argument(TestFrameworks.Specs2, "exclude", "DockerComposeTag"))
lazy val myProject =
(project in file("myProject"))
.enablePlugins(DockerPlugin, DockerComposePlugin)
.config(DockerTest)
.settings(inConfig(DockerTest)(Defaults.testTasks): _*)
.settings(testOptions in DockerTest := Seq(
Tests.Argument(TestFrameworks.Specs2, "include","DockerComposeTag"))
)
// We exclude in other tests
.settings(testOptions in Test := Seq(
lazy val myProject =
(project in file("myProject"))
.enablePlugins(DockerPlugin, DockerComposePlugin)
.config(DockerTest)
.settings(inConfig(DockerTest)(Defaults.testTasks): _*)
.settings(testOptions in DockerTest := Seq(
Tests.Argument(TestFrameworks.Specs2, "include", "DockerComposeTag"))
)
lazy val DockerTest = config("docker-int") extend Test
import cats.free.Free
import cats.{ Monad, ~>}
import iota._
import TListK.:::
import cats.implicits._
// A monkey patching that was possible with Free Monad, where logging is
// never a part of the algebra/interface/interpreter.
// Unlike dozens of blogs and patterns, here Log is never a part of the coproduct of algebras
// (which can clutter the business-logic/monadic-for-comprehension).
package com.telstra.dxmodel.api.interop
import cats.data.{EitherT, Kleisli, Writer, WriterT}
import cats.free.Free
import cats.implicits._
import cats.~>
import scalaz.zio.IO
import com.telstra.dxmodel.instances.AllMonadInstances._
import cats.data.{EitherT, Writer, WriterT}
import cats.free.Free
import cats.implicits._
import cats.{~>}
import scalaz.zio.IO
// Technique to build a computation description which should accumulate info on each execution step
// which is to be returned to the user regardless of failure or success.