diff --git a/build.sbt b/build.sbt index 7e6c4ce..0faf8f6 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType} -val catsV = "2.1.1" +val catsV = "2.7.0" val catsEffectV = "3.3.1" val fs2V = "3.2.3" val http4sV = "0.23.7" @@ -32,9 +32,9 @@ lazy val examples = project.in(file("examples")) name := "whale-tail-examples", libraryDependencies ++= Seq( "org.typelevel" %% "log4cats-slf4j" % log4catsV, - "ch.qos.logback" % "logback-classic" % "1.2.3", + "ch.qos.logback" % "logback-classic" % "1.2.10", "org.http4s" %% "http4s-ember-server" % http4sV, - "com.github.jnr" % "jnr-unixsocket" % "0.38.11", + "com.github.jnr" % "jnr-unixsocket" % "0.38.15", ) ) @@ -74,6 +74,9 @@ lazy val commonSettings = Seq( "org.typelevel" %% "log4cats-core" % log4catsV, "org.typelevel" %% "log4cats-testing" % log4catsV % Test, + "com.github.jnr" % "jnr-unixsocket" % "0.38.15" % Test, + + "org.typelevel" %% "cats-effect-testing-specs2" % "1.4.0" % Test, "org.specs2" %% "specs2-core" % specs2V % Test, "org.specs2" %% "specs2-scalacheck" % specs2V % Test diff --git a/core/src/main/scala/io/chrisdavenport/whaletail/System.scala b/core/src/main/scala/io/chrisdavenport/whaletail/System.scala new file mode 100644 index 0000000..de3801a --- /dev/null +++ b/core/src/main/scala/io/chrisdavenport/whaletail/System.scala @@ -0,0 +1,20 @@ +package io.chrisdavenport.whaletail + +import cats.effect._ +import org.http4s._ +import org.http4s.client.Client +import io.circe._ +import org.http4s.circe._ + +object System { + object Operations { + def info[F[_]: Concurrent](client: Client[F]): F[Json] = + client.expect[Json](Request[F](Method.GET, Docker.versionPrefix / "info")) + + def version[F[_]: Concurrent](client: Client[F]): F[Json] = + client.expect[Json](Request[F](Method.GET, Docker.versionPrefix / "version")) + + def ping[F[_]: Concurrent](client: Client[F]): F[Boolean] = + client.successful(Request[F](Method.HEAD, Docker.versionPrefix / "_ping")) + } +} \ No newline at end of file diff --git a/core/src/test/scala/io/chrisdavenport/whaletail/SystemSpec.scala b/core/src/test/scala/io/chrisdavenport/whaletail/SystemSpec.scala new file mode 100644 index 0000000..d22e413 --- /dev/null +++ b/core/src/test/scala/io/chrisdavenport/whaletail/SystemSpec.scala @@ -0,0 +1,32 @@ +package io.chrisdavenport.whaletail + +import org.specs2._ +import cats.effect._ +import cats.effect.testing.specs2.CatsEffect + +object SystemSpec extends mutable.Specification with CatsEffect { + + "System" should { + "be able to get info" in { + Docker.client[IO].use(c => + System.Operations.info(c).attempt + .map(e => e must beRight) + ) + } + + "be able to get version" in { + Docker.client[IO].use(c => + System.Operations.version(c).attempt + .map(e => e must beRight) + ) + } + + "be able to ping" in { + Docker.client[IO].use(c => + System.Operations.ping(c).attempt + .map(e => e must beRight) + ) + } + } + +} \ No newline at end of file