-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #183 from davenverse/addSystemCalls
Add System Calls
- Loading branch information
Showing
3 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
core/src/main/scala/io/chrisdavenport/whaletail/System.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
core/src/test/scala/io/chrisdavenport/whaletail/SystemSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
) | ||
} | ||
} | ||
|
||
} |