Repository: scala-steward-org/scala-steward
Pull request #1544 (2020-07-15 17:39:42)

Test Traverse[Scope] instance


Patch:
diff --git a/build.sbt b/build.sbt
index b0a5793e..902b67eb 100644
--- a/build.sbt
+++ b/build.sbt
@@ -55,7 +55,7 @@ lazy val core = myCrossProject("core")
       Dependencies.scalacacheCaffeine,
       Dependencies.scalacacheCatsEffect,
       Dependencies.logbackClassic % Runtime,
-      Dependencies.catsKernelLaws % Test,
+      Dependencies.catsLaws % Test,
       Dependencies.circeLiteral % Test,
       Dependencies.disciplineScalatest % Test,
       Dependencies.http4sDsl % Test,
diff --git a/project/Dependencies.scala b/project/Dependencies.scala
index 46f80d65..4e888fc0 100644
--- a/project/Dependencies.scala
+++ b/project/Dependencies.scala
@@ -11,7 +11,7 @@ object Dependencies {
   val betterMonadicFor = "com.olegpy" %% "better-monadic-for" % "0.3.1"
   val caseApp = "com.github.alexarchambault" %% "case-app" % "2.0.3"
   val catsEffect = "org.typelevel" %% "cats-effect" % "2.1.4"
-  val catsKernelLaws = "org.typelevel" %% "cats-kernel-laws" % "2.1.1"
+  val catsLaws = "org.typelevel" %% "cats-laws" % "2.1.1"
   val circeConfig = "io.circe" %% "circe-config" % "0.8.0"
   val circeGeneric = "io.circe" %% "circe-generic" % "0.13.0"
   val circeGenericExtras = "io.circe" %% "circe-generic-extras" % "0.13.0"


Test patch:
diff --git a/modules/core/src/test/scala/org/scalasteward/core/TestInstances.scala b/modules/core/src/test/scala/org/scalasteward/core/TestInstances.scala
index 19dc717a..8627203d 100644
--- a/modules/core/src/test/scala/org/scalasteward/core/TestInstances.scala
+++ b/modules/core/src/test/scala/org/scalasteward/core/TestInstances.scala
@@ -4,7 +4,7 @@ import _root_.io.chrisdavenport.log4cats.Logger
 import _root_.io.chrisdavenport.log4cats.slf4j.Slf4jLogger
 import cats.effect.{ContextShift, IO, Timer}
 import org.scalacheck.{Arbitrary, Cogen, Gen}
-import org.scalasteward.core.data.Version
+import org.scalasteward.core.data.{Resolver, Scope, Version}
 import org.scalasteward.core.util.Change
 import org.scalasteward.core.util.Change.{Changed, Unchanged}
 import scala.concurrent.ExecutionContext
@@ -22,6 +22,16 @@ object TestInstances {
   implicit val ioTimer: Timer[IO] =
     IO.timer(ExecutionContext.global)
 
+  implicit def scopeArbitrary[T](implicit arbT: Arbitrary[T]): Arbitrary[Scope[T]] =
+    Arbitrary(
+      arbT.arbitrary.flatMap { t =>
+        Gen.oneOf(Scope(t, List.empty), Scope(t, List(Resolver.mavenCentral)))
+      }
+    )
+
+  implicit def scopeCogen[T](implicit cogenT: Cogen[T]): Cogen[Scope[T]] =
+    cogenT.contramap(_.value)
+
   implicit val versionArbitrary: Arbitrary[Version] = {
     val versionChar = Gen.frequency(
       (8, Gen.numChar),
diff --git a/modules/core/src/test/scala/org/scalasteward/core/data/ScopeTest.scala b/modules/core/src/test/scala/org/scalasteward/core/data/ScopeTest.scala
new file mode 100644
index 00000000..b30897d8
--- /dev/null
+++ b/modules/core/src/test/scala/org/scalasteward/core/data/ScopeTest.scala
@@ -0,0 +1,15 @@
+package org.scalasteward.core.data
+
+import cats.implicits._
+import cats.kernel.laws.discipline.OrderTests
+import cats.laws.discipline.TraverseTests
+import org.scalasteward.core.TestInstances._
+import org.scalatest.funsuite.AnyFunSuite
+import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks
+import org.typelevel.discipline.scalatest.FunSuiteDiscipline
+
+class ScopeTest extends AnyFunSuite with FunSuiteDiscipline with ScalaCheckPropertyChecks {
+  checkAll("Traverse[Scope]", TraverseTests[Scope].traverse[Int, Int, Int, Int, Option, Option])
+
+  checkAll("Order[Scope[Int]]", OrderTests[Scope[Int]].order)
+}