From 7ee706e2d525d706fe2140c3a1db216d24268358 Mon Sep 17 00:00:00 2001 From: Denys Fakhritdinov Date: Fri, 1 Dec 2023 12:39:50 +0100 Subject: [PATCH] add MDC concatenate test (#253) Co-authored-by: Denys Fakhritdinov --- .../com/evolutiongaming/catshelper/LogSpec.scala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/src/test/scala/com/evolutiongaming/catshelper/LogSpec.scala b/core/src/test/scala/com/evolutiongaming/catshelper/LogSpec.scala index efeb5967..740fd081 100644 --- a/core/src/test/scala/com/evolutiongaming/catshelper/LogSpec.scala +++ b/core/src/test/scala/com/evolutiongaming/catshelper/LogSpec.scala @@ -120,6 +120,21 @@ class LogSpec extends AnyFunSuite with Matchers { )) } + test("preset MDC concatenates with in-place MDC") { + + val stateT = for { + log0 <- logOf("source") + log = log0.withMdc(Log.Mdc.Eager("preset" -> "value")) + _ <- log.info("info", Log.Mdc.Eager("info" -> "value")) + } yield {} + + val (state, _) = stateT.run(State(Nil)) + state shouldEqual State(List( + Action.Info("info", Log.Mdc.Eager("info" -> "value", "preset" -> "value")), + Action.OfStr("source") + )) + } + test("MDC cleanup") { val io = for {