Skip to content

Commit

Permalink
fix: Restore ReporterSpec tests (#51)
Browse files Browse the repository at this point in the history
* fix: Restore ReporterSpec tests

* fix: unused import

* fix: bump scala js

* fix: upgrade to scala 3.3.1

* fix: bump scalaa 3 in build

* fix: bump scala-native

* fix: update README

* hmm

* fix: one last try before i burn the whole thing

---------

Co-authored-by: Regis Kuckaertz <regiskuckaertz@users.noreply.github.com>
  • Loading branch information
regiskuckaertz and regiskuckaertz committed Nov 16, 2023
1 parent 63d8066 commit ed2b59f
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
fail-fast: false
matrix:
java: ['8', '11', '17']
scala: ['2.12.17', '2.13.10', '3.2.2']
scala: ['2.12.17', '2.13.10', '3.3.1']
platform: ['JVM', 'JS', 'Native']
steps:
- name: Checkout current branch
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ addCommandAlias(
";mockNative/compile"
)

val zioVersion = "2.0.12"
val zioVersion = "2.0.19"

lazy val root = (project in file("."))
.aggregate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import java.time.Instant
object MockReporterSpec extends ZIOSpecDefault {
import Expectation._
import Assertion._
import TestAspect.ignore

val andSuite = suite("And")(
test("render `And`") {
Expand Down Expand Up @@ -103,7 +102,7 @@ object MockReporterSpec extends ZIOSpecDefault {
"Your test case"
),
output.contains(
"that there should have been no calls to the mock zio.mock.MockConsole. However zio.mock.MockConsole.Print(foo) was called unexpectedly.()"
"that there should have been no calls to the mock zio.mock.MockConsole. However zio.mock.MockConsole.Print(foo) was called unexpectedly."
)
)
}
Expand All @@ -124,7 +123,7 @@ object MockReporterSpec extends ZIOSpecDefault {
"⚠ Expected the call zio.mock.MockConsole.Print(equalTo(foo)) on zio.mock.MockConsole which satisfies the assertion equalTo(foo). It should have been called exactly 2 times but was only called once. As such, it is considered partially satisfied."
),
output.contains(
"✖ Expected the call zio.mock.MockClock.Instant(isUnit()) on zio.mock.MockClock which satisfies the assertion isUnit(). However, it was never called and is considered unsatisfied."
"✖ Expected the call zio.mock.MockClock.Instant(isUnit) on zio.mock.MockClock which satisfies the assertion isUnit. However, it was never called and is considered unsatisfied."
),
output.contains(
"✖ Expected the call zio.mock.MockConsole.PrintLine(equalTo(bar)) on zio.mock.MockConsole which satisfies the assertion equalTo(bar). It should have been called anywhere from 2 to 5 time but was never called. As such, it is considered unsatisfied."
Expand All @@ -145,7 +144,7 @@ object MockReporterSpec extends ZIOSpecDefault {
}

}
) @@ ignore // TODO: reenable this test suite
)
val expectation =
MockConsole.Print(Assertion.equalTo("foo"), unit).twice ++ MockClock.Instant(
value(Instant.ofEpochMilli(0))
Expand Down Expand Up @@ -208,7 +207,7 @@ object MockReporterSpec extends ZIOSpecDefault {

override def spec = suite("MockReporterSpec")(
behaviorSuite,
visualCheckSuite @@ ignore // Remove `ignore` to view failures in all their colorful glory.
visualCheckSuite
)

}
9 changes: 3 additions & 6 deletions mock-tests/shared/src/test/scala/zio/test/MockUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package zio.test

import zio._
import zio.mock.testing._
import zio.test.results._

object MockUtils {

Expand Down Expand Up @@ -31,11 +30,9 @@ object MockUtils {

val testOutput = if (showSpecOutput) TestOutput.live else ZLayer.succeed(SilentTestOutput)
val layer0 = testEnvironment ++ Scope.default ++ ZIOAppArgs.empty
val layer1 = TestLogger.fromConsole(
Console.ConsoleLive
) >+> ExecutionEventConsolePrinter.live(
ReporterEventRenderer.ConsoleEventRenderer
) >+> ResultFileOpsJson.live >+> ResultSerializer.live >+> ExecutionEventJsonPrinter.live >+> ExecutionEventPrinter.live >+> testOutput >+> ExecutionEventSink.live
val layer1 = ExecutionEventPrinter.live(Console.ConsoleLive, ReporterEventRenderer.ConsoleEventRenderer) >+>
testOutput >+>
ExecutionEventSink.live

// perTestLayer = (ZLayer.succeedEnvironment(environment1) ++ ZEnv.live) >>> (TestEnvironment.live ++ ZLayer
// .environment[Scope] ++ ZLayer.environment[ZIOAppArgs])
Expand Down
3 changes: 1 addition & 2 deletions mock/shared/src/main/scala/zio/mock/MockReporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ object MockReporter {
}

private def makeTestFailure(messages: Seq[String]) = {

val ass = Assertion.assertion[Any](
messages.mkString(" " + prefix(ExpectationState.Unsatisfied))
)(_ => false)
Expand Down Expand Up @@ -113,7 +112,7 @@ object MockReporter {

}

private def renderAssertion(ass: Assertion[_]): String = bold(magenta(ass.toString()))
private def renderAssertion(ass: Assertion[_]): String = bold(magenta(ass.render))

private def renderMock(in: Mock[_]): String = {
val fragments = in.getClass.getName.replaceAll("\\$", ".").split("\\.")
Expand Down
2 changes: 1 addition & 1 deletion project/BuildHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object BuildHelper {
}
val Scala212: String = versions("2.12")
val Scala213: String = versions("2.13")
val Scala3: String = versions("3.2")
val Scala3: String = versions("3.3")

val SilencerVersion = "1.7.12"
val SjsJavaTimeVersion = "2.3.0"
Expand Down
8 changes: 4 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies"
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.0.1")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.12.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.12")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.14.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.16")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("pl.project13.scala" % "sbt-jcstress" % "0.2.0")
Expand Down

0 comments on commit ed2b59f

Please sign in to comment.