Skip to content

Commit

Permalink
Update scalatest to 3.1.0 (#656)
Browse files Browse the repository at this point in the history
* Update scalatest to 3.1.0

* Include org.scalatestplus.scalacheck-1-14 and fix deprecated imports
  • Loading branch information
scala-steward authored and ruippeixotog committed Dec 8, 2019
1 parent d3bc58c commit 321c9fc
Show file tree
Hide file tree
Showing 19 changed files with 81 additions and 97 deletions.
Expand Up @@ -5,11 +5,13 @@ import scala.concurrent.duration._
import akka.actor.ActorPath
import akka.util.Timeout
import com.typesafe.config.ConfigFactory
import org.scalatest._
import org.scalatest.EitherValues
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import pureconfig.generic.auto._
import pureconfig.syntax._

class AkkaSuite extends FlatSpec with Matchers with EitherValues {
class AkkaSuite extends AnyFlatSpec with Matchers with EitherValues {

case class TimeoutConf(timeout: Timeout)
case class PathConf(path: ActorPath)
Expand Down
42 changes: 2 additions & 40 deletions modules/cats/src/test/scala/pureconfig/module/cats/CatsSuite.scala
@@ -1,53 +1,15 @@
package pureconfig.module.cats

import scala.collection.immutable.{ SortedMap, SortedSet }
import scala.reflect.runtime.universe._

import cats.data._
import cats.implicits._
import com.typesafe.config.ConfigFactory.parseString
import com.typesafe.config.{ ConfigRenderOptions, ConfigValue }
import org.scalactic.Equality
import org.scalatest.EitherValues
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.Matcher
import org.scalatest.matchers.should.Matchers
import pureconfig.error.{ ConfigReaderFailures, ConfigValueLocation, ConvertFailure, FailureReason }
import pureconfig.BaseSuite
import pureconfig.generic.auto._
import pureconfig.syntax._
import pureconfig.{ ConfigReader, ConfigWriter }

class CatsSuite extends AnyFlatSpec with Matchers with EitherValues {

// `discipline-scalatest` currently depends on a snapshot version of ScalaTest which doesn't provide FlatSpec. We have
// the following checks under `ConfigConvertChecks` of our `tests` package, which requires types extending it to
// extend from `FlatSpec`. Since we can't extend `ConfigConvertChecks` here, the relevant checks are copied for
// convenience. We should be able to remove them once a stable version of `discipline-scalatest` is released and we
// update ScalaTest.
def checkRead[T: Equality](reprsToValues: (ConfigValue, T)*)(implicit cr: ConfigReader[T], tpe: TypeTag[T]): Unit =
for ((repr, value) <- reprsToValues) {
it should s"read the value $value of type ${tpe.tpe} from ${repr.render(ConfigRenderOptions.concise())}" in {
cr.from(repr).right.value shouldEqual value
}
}

def checkWrite[T: Equality](valuesToReprs: (T, ConfigValue)*)(implicit cw: ConfigWriter[T], tpe: TypeTag[T]): Unit =
for ((value, repr) <- valuesToReprs) {
it should s"write the value $value of type ${tpe.tpe} to ${repr.render(ConfigRenderOptions.concise())}" in {
cw.to(value) shouldEqual repr
}
}

def checkReadWrite[T: ConfigReader: ConfigWriter: TypeTag: Equality](reprsValues: (ConfigValue, T)*): Unit = {
checkRead[T](reprsValues: _*)
checkWrite[T](reprsValues.map(_.swap): _*)
}

def failWith(
reason: FailureReason,
path: String,
location: Option[ConfigValueLocation] = None): Matcher[ConfigReader.Result[Any]] =
be(Left(ConfigReaderFailures(ConvertFailure(reason, location, path), Nil)))
class CatsSuite extends BaseSuite {

case class Numbers(numbers: NonEmptyList[Int])
case class NumVec(numbers: NonEmptyVector[Int])
Expand Down
@@ -1,14 +1,16 @@
package pureconfig.module.circe

import com.typesafe.config.ConfigFactory
import io.circe._
import io.circe.literal._
import org.scalatest._
import com.typesafe.config.{ ConfigFactory, ConfigValue }
import org.scalatest.EitherValues
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import pureconfig._
import pureconfig.syntax._
import pureconfig.generic.auto._
import pureconfig.syntax._

class CirceSuite extends FlatSpec with Matchers with EitherValues {
class CirceSuite extends AnyFlatSpec with Matchers with EitherValues {

case class JsonConf(json: Json)
val confJson = json"""{ "long": 123, "double": 123.123, "alpha": "test", "arr": [1, 2, 3], "map": { "key1": "value1", "key2": "value2" } }"""
Expand Down
19 changes: 10 additions & 9 deletions modules/fs2/src/test/scala/pureconfig/module/fs2Suite.scala
@@ -1,18 +1,19 @@
package pureconfig.module

import cats.effect.{ IO, Timer }
import scala.concurrent.ExecutionContext
import scala.concurrent.duration._

import _root_.fs2.{ Stream, text }
import cats.effect.{ IO, Timer }
import cats.implicits._
import org.scalatest.EitherValues._
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import pureconfig.error.ConfigReaderException
import pureconfig.generic.auto._
import pureconfig.module.{ fs2 => testee }
import org.scalatest.{ FlatSpec, Matchers }
import pureconfig.error.ConfigReaderException
import org.scalatest.EitherValues._
import scala.concurrent.duration._
import cats.implicits._

import scala.concurrent.ExecutionContext

class fs2Suite extends FlatSpec with Matchers {
class fs2Suite extends AnyFlatSpec with Matchers {

implicit val timer: Timer[IO] = IO.timer(ExecutionContext.global)

Expand Down
@@ -1,14 +1,15 @@
package pureconfig.module.javax

import _root_.javax.security.auth.kerberos.KerberosPrincipal
import javax.security.auth.x500.X500Principal

import com.typesafe.config.ConfigFactory
import org.scalatest._
import javax.security.auth.x500.X500Principal
import org.scalatest.EitherValues
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import pureconfig.generic.auto._
import pureconfig.syntax._

class JavaxSuite extends FlatSpec with Matchers with EitherValues {
class JavaxSuite extends AnyFlatSpec with Matchers with EitherValues {

case class K5Conf(principal: KerberosPrincipal)

Expand Down
Expand Up @@ -3,11 +3,13 @@ package pureconfig.module.scalaxml
import scala.xml.Elem

import com.typesafe.config.ConfigFactory.parseString
import org.scalatest._
import org.scalatest.EitherValues
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import pureconfig.generic.auto._
import pureconfig.syntax._

class ScalaXMLSuite extends FlatSpec with Matchers with EitherValues {
class ScalaXMLSuite extends AnyFlatSpec with Matchers with EitherValues {

case class Config(people: Elem)

Expand Down
Expand Up @@ -2,18 +2,17 @@ package pureconfig.module.scalaz

import com.typesafe.config.ConfigValue
import org.scalacheck.{ Prop, Properties }
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite
import org.scalatestplus.scalacheck.Checkers
import pureconfig.{ ConfigConvert, ConfigReader, ConfigWriter }
import pureconfig.error.ConfigReaderFailures
import pureconfig.module.scalaz.arbitrary._
import pureconfig.module.scalaz.equal._
import pureconfig.module.scalaz.instances._

import pureconfig.{ ConfigConvert, ConfigReader, ConfigWriter }
import scalaz.scalacheck.ScalazProperties._
import scalaz.std.anyVal.intInstance

class ScalazLawsSuite extends FunSuite with Checkers {
class ScalazLawsSuite extends AnyFunSuite with Checkers {
import ScalazLawsSuite._

test("contravariant.laws[ConfigWriter]") {
Expand Down
Expand Up @@ -10,7 +10,7 @@ import scalaz.scalacheck.ScalazArbitrary._
import scalaz.std.anyVal.intInstance
import scalaz.std.string._

class ScalazSuite extends BaseSuite with ConfigConvertChecks {
class ScalazSuite extends BaseSuite {
import ScalazSuite._

checkArbitrary[Maybe[Int]]
Expand Down
18 changes: 10 additions & 8 deletions project/Dependencies.scala
Expand Up @@ -3,24 +3,26 @@ import sbt._
object Dependencies {

object Version {
val scala211 = "2.11.12"
val scala212 = "2.12.10"
val scala213 = "2.13.0"
val scala211 = "2.11.12"
val scala212 = "2.12.10"
val scala213 = "2.13.0"

val shapeless = "2.3.3"
val typesafeConfig = "1.4.0"
val shapeless = "2.3.3"
val typesafeConfig = "1.4.0"

val scalaTest = "3.0.8"
val scalaTest = "3.1.0"
val scalaTestPlusScalaCheck = "3.1.0.0"

val scalaCheck = "1.14.2"
val scalaCheckShapeless = "1.2.3"
val scalaCheck = "1.14.2"
val scalaCheckShapeless = "1.2.3"
}

val shapeless = "com.chuusai" %% "shapeless" % Version.shapeless
val typesafeConfig = "com.typesafe" % "config" % Version.typesafeConfig

// testing libraries
val scalaTest = "org.scalatest" %% "scalatest" % Version.scalaTest
val scalaTestPlusScalaCheck = "org.scalatestplus" %% "scalacheck-1-14" % Version.scalaTestPlusScalaCheck
val scalaCheck = "org.scalacheck" %% "scalacheck" % Version.scalaCheck
val scalaCheckShapeless =
"com.github.alexarchambault" %% s"scalacheck-shapeless_1.14" % Version.scalaCheckShapeless
Expand Down
1 change: 1 addition & 0 deletions tests/build.sbt
Expand Up @@ -5,6 +5,7 @@ name := "pureconfig-tests"
libraryDependencies ++= Seq(
scalaTest,
scalaCheck,
scalaTestPlusScalaCheck,
scalaCheckShapeless % "test")

skip in publish := true
6 changes: 4 additions & 2 deletions tests/src/main/scala/pureconfig/BaseSuite.scala
@@ -1,10 +1,12 @@
package pureconfig

import org.scalatest.{ EitherValues, FlatSpec, Matchers }
import org.scalatest.EitherValues
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

class BaseSuite
extends FlatSpec
extends AnyFlatSpec
with ConfigConvertChecks
with Matchers
with ConfigReaderMatchers
Expand Down
6 changes: 4 additions & 2 deletions tests/src/main/scala/pureconfig/ConfigConvertChecks.scala
Expand Up @@ -6,15 +6,17 @@ import scala.reflect.runtime.universe._
import com.typesafe.config.{ ConfigRenderOptions, ConfigValue, ConfigValueFactory }
import org.scalacheck.Arbitrary
import org.scalactic.Equality
import org.scalatest.{ EitherValues, FlatSpec, Matchers }
import org.scalatest.EitherValues
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks

import pureconfig.error._
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

/**
* Add utilities to a scalatest `FlatSpec` to test `ConfigConvert` instances
*/
trait ConfigConvertChecks { this: FlatSpec with Matchers with ScalaCheckDrivenPropertyChecks with EitherValues =>
trait ConfigConvertChecks { this: AnyFlatSpec with Matchers with ScalaCheckDrivenPropertyChecks with EitherValues =>

/**
* For each value of type `T`, check that the value produced by converting to and then from `ConfigValue` is the same
Expand Down
4 changes: 3 additions & 1 deletion tests/src/main/scala/pureconfig/ConfigReaderMatchers.scala
Expand Up @@ -5,8 +5,10 @@ import scala.reflect.ClassTag
import org.scalatest._
import org.scalatest.matchers.{ MatchResult, Matcher }
import pureconfig.error._
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

trait ConfigReaderMatchers { this: FlatSpec with Matchers =>
trait ConfigReaderMatchers { this: AnyFlatSpec with Matchers =>

def failWith(reason: FailureReason): Matcher[ConfigReader.Result[Any]] =
matchPattern { case Left(ConfigReaderFailures(ConvertFailure(`reason`, _, _), Nil)) => }
Expand Down
5 changes: 3 additions & 2 deletions tests/src/test/scala/pureconfig/ConfigFieldMappingSuite.scala
@@ -1,8 +1,9 @@
package pureconfig

import org.scalatest.{ FlatSpec, Matchers }
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

class ConfigFieldMappingSuite extends FlatSpec with Matchers {
class ConfigFieldMappingSuite extends AnyFlatSpec with Matchers {

behavior of "ConfigFieldMapping"

Expand Down
Expand Up @@ -3,19 +3,20 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package pureconfig

import com.typesafe.config._
import java.net.URL
import java.nio.file.Paths
import org.scalatest._
import shapeless._

import com.typesafe.config._
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import pureconfig.error._
import pureconfig.generic.auto._
import pureconfig.generic.error._
import pureconfig.generic.hlist._
import pureconfig.syntax._
import shapeless._

class ConfigReaderExceptionSuite extends FlatSpec with Matchers {
class ConfigReaderExceptionSuite extends AnyFlatSpec with Matchers {
behavior of "ConfigReaderException"

case class Conf(a: Int, b: String, c: Int)
Expand Down
Expand Up @@ -6,14 +6,16 @@ package pureconfig
import java.net.URL

import com.typesafe.config.{ ConfigFactory, ConfigValueType }
import org.scalatest._
import org.scalatest.EitherValues
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import pureconfig.error._
import pureconfig.generic.auto._

/**
* Suite of tests related to the location of ConfigValues that raised failures.
*/
class ConfigReaderFailureLocationSuite extends FlatSpec with Matchers with EitherValues {
class ConfigReaderFailureLocationSuite extends AnyFlatSpec with Matchers with EitherValues {
"Loading configuration from files" should "show proper error locations when loading a single file" in {
import pureconfig.syntax._
case class Conf(a: Int, b: String, c: Int)
Expand Down
Expand Up @@ -3,18 +3,18 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package pureconfig

import com.typesafe.config._
import java.net.URL
import org.scalatest._

import com.typesafe.config._
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import pureconfig.error._
import pureconfig.generic.error._
import java.nio.file.Path

/**
* Suite of tests related to the pretty printing of config reader failures.
*/
class ConfigReaderFailuresPrettyPrintSuite extends FlatSpec with Matchers {
class ConfigReaderFailuresPrettyPrintSuite extends AnyFlatSpec with Matchers {
"A ConfigReaderFailures prettyPrint method" should "print errors with a configurable identation" in {

def location(line: Int) = ConfigValueLocation(new URL("file:///tmp/config"), line)
Expand Down
5 changes: 3 additions & 2 deletions tests/src/test/scala/pureconfig/NamingConventionSuite.scala
@@ -1,8 +1,9 @@
package pureconfig

import org.scalatest.{ FlatSpec, Matchers }
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

class NamingConventionSuite extends FlatSpec with Matchers {
class NamingConventionSuite extends AnyFlatSpec with Matchers {
"CamelCase" should "properly tokenize words" in {
CamelCase.toTokens("lowercase") shouldBe Seq("lowercase")
CamelCase.toTokens("Class") shouldBe Seq("class")
Expand Down
9 changes: 5 additions & 4 deletions tests/src/test/scala/pureconfig/syntax/SyntaxSpec.scala
@@ -1,13 +1,14 @@
package pureconfig.syntax

import scala.collection.immutable.{ List, Map }

import com.typesafe.config.ConfigFactory
import org.scalatest.{ FlatSpec, Matchers }
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import pureconfig.error.ConfigReaderException
import pureconfig.generic.auto._

import scala.collection.immutable.{ List, Map }

class SyntaxSpec extends FlatSpec with Matchers {
class SyntaxSpec extends AnyFlatSpec with Matchers {

behavior of "pureconfig.syntax._"

Expand Down

0 comments on commit 321c9fc

Please sign in to comment.