Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zio 2.1.14, test fixes #922

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ inThisBuild(
),
Developer("justcoon", "Peter Kotula", "[email protected]", url("https://github.com/justcoon"))
),
zioVersion := "2.1.13",
zioVersion := "2.1.14",
scala213 := "2.13.15"
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ object JsonLogFormatSpec extends ZIOSpecDefault {
},
test("numeric value") {
val format = label("line", traceLine)
check(Gen.int) { i =>
check(Gen.int(1, 1000)) { i =>
val result = format.toJsonLogger(
Trace.apply("", "", i),
FiberId.None,
Expand All @@ -161,7 +161,7 @@ object JsonLogFormatSpec extends ZIOSpecDefault {
},
test("numeric value concatenated with string") {
val format = label("line", traceLine |-| line)
check(Gen.alphaNumericString, Gen.int) { (line, i) =>
check(Gen.alphaNumericString, Gen.int(1, 1000)) { (line, i) =>
val result = format.toJsonLogger(
Trace.apply("", "", i),
FiberId.None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object LogFilterSpec extends ZIOSpecDefault {
expectation: Assertion[Boolean]
): TestResult =
assert(
filter(Trace(location, "", 0), FiberId.None, level, () => "", Cause.empty, FiberRefs.empty, List.empty, Map.empty)
filter(Trace(location, "", 1), FiberId.None, level, () => "", Cause.empty, FiberRefs.empty, List.empty, Map.empty)
)(expectation ?? s"$location with $level")

private def testFilterAnnotation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ object LogFormatSpec extends ZIOSpecDefault {
},
test("traceLine") {
val format = LogFormat.traceLine
check(Gen.int) { tLine =>
check(Gen.int(1, 2000)) { tLine =>
val result = format.toLogger(
Trace("location", "file", tLine),
FiberId.None,
Expand Down
10 changes: 5 additions & 5 deletions core/shared/src/test/scala/zio/logging/LogGroupSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object LogGroupSpec extends ZIOSpecDefault {
val group = LogGroup.loggerName
check(Gen.alphaNumericString) { value =>
val result = group(
Trace.apply(value, "", 0),
Trace.apply(value, "", 1),
FiberId.None,
LogLevel.Info,
() => "",
Expand Down Expand Up @@ -58,7 +58,7 @@ object LogGroupSpec extends ZIOSpecDefault {
check(Gen.alphaNumericString, Gen.elements(LogLevel.Info, LogLevel.Warning, LogLevel.Error, LogLevel.Debug)) {
(value, level) =>
val result = group(
Trace.apply(value, "", 0),
Trace.apply(value, "", 1),
FiberId.None,
level,
() => "",
Expand All @@ -75,7 +75,7 @@ object LogGroupSpec extends ZIOSpecDefault {
check(Gen.alphaNumericString, Gen.elements(LogLevel.Info, LogLevel.Warning, LogLevel.Error, LogLevel.Debug)) {
(value, level) =>
val result = group(
Trace.apply(value, "", 0),
Trace.apply(value, "", 1),
FiberId.None,
level,
() => "",
Expand Down Expand Up @@ -107,7 +107,7 @@ object LogGroupSpec extends ZIOSpecDefault {
val group = LogGroup.loggerName.map("PREFIX_" + _)
check(Gen.alphaNumericString) { value =>
val result = group(
Trace.apply(value, "", 0),
Trace.apply(value, "", 1),
FiberId.None,
LogLevel.Info,
() => "",
Expand All @@ -124,7 +124,7 @@ object LogGroupSpec extends ZIOSpecDefault {
check(Gen.alphaNumericString, Gen.elements(LogLevel.Info, LogLevel.Warning, LogLevel.Error, LogLevel.Debug)) {
(value, level) =>
val result = group(
Trace.apply(value, "", 0),
Trace.apply(value, "", 1),
FiberId.None,
level,
() => "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object LoggerNameExtractorSpec extends ZIOSpecDefault {
} else trace
}
val result = extractor(
Trace.apply(trace, "", 0),
Trace.apply(trace, "", 1),
Copy link
Member

@guizmaii guizmaii Jan 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justcoon Can I ask why you need to change these 0 into 1? 🤔

I made a bunch of changes in zio.Trace but I'm not sure to understand what would require this change here. Did I introduce an issue? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @guizmaii , look like there is some issue with latest change

import zio.test._
import zio.Trace

object TraceSpec extends ZIOSpecDefault {

  val spec: Spec[Environment, Any] = suite("TraceSpec")(
    test("line") {
      val expected = 0

      val trace = Trace.apply("", "", expected)

      val line = trace match {
        case Trace(_, _, line) => line
        case _                 => -1
      }

      assertTrue(line == expected)

    }
  )
}

fail with

Assertion failed:
Expected :0
Actual   :-1
<Click to see difference>

  ✗ -1 was not equal to 0
  line == expected
  line = -1

however, I guessed that in reality there will not be Trace with line=0, so I just updated tests

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I guess the previous behaviour was kind of incorrect as the Trace.unapply should probably have returned None for an empty String, don't you think? 🤔

FiberRefs.empty,
annotations
)
Expand All @@ -49,7 +49,7 @@ object LoggerNameExtractorSpec extends ZIOSpecDefault {
} else trace
}
val result = extractor(
Trace.apply(trace, "", 0),
Trace.apply(trace, "", 1),
FiberRefs.empty,
annotations
)
Expand All @@ -76,7 +76,7 @@ object LoggerNameExtractorSpec extends ZIOSpecDefault {
trace.substring(0, last)
} else trace
val result = extractor(
Trace.apply(trace, "", 0),
Trace.apply(trace, "", 1),
FiberRefs.empty,
Map.empty
)
Expand Down
2 changes: 1 addition & 1 deletion project/Versions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object Versions {
val zioMetricsConnectorsVersion = "2.3.1"
val zioConfig = "4.0.3"
val zioParser = "0.1.11"
val zioPrelude = "1.0.0-RC35"
val zioPrelude = "1.0.0-RC36"
val zioHttp = "3.0.1"
val log4jVersion = "2.24.3"
}
Loading