-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix LogTree * Change to LinkedHashMap for consistent field order
- Loading branch information
1 parent
01bf629
commit ac55b6e
Showing
2 changed files
with
28 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
modules/logging/structured/src/test/scala/tofu/logging/LogTreeSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package tofu.logging | ||
|
||
import cats.syntax.semigroup._ | ||
import org.scalatest.funsuite.AnyFunSuite | ||
import tofu.logging.{LogTree, TethysBuilder} | ||
import tofu.syntax.logRenderer._ | ||
class LogTreeSuite extends AnyFunSuite { | ||
|
||
case class Data(field1: String, field2: Int) | ||
|
||
object Data { | ||
implicit object loggable extends DictLoggable[Data] with ToStringLoggable[Data] { | ||
def fields[I, V, R, S](a: Data, i: I)(implicit r: LogRenderer[I, V, R, S]): R = | ||
i.addString("field1", a.field1) |+| | ||
i.addInt("field2", a.field2.toLong) | ||
} | ||
|
||
} | ||
|
||
val value = Map("aaaa" -> List(Data("lol", 2), Data("kek", -1))) | ||
|
||
test("LogTree and tethys builder results are consistent") { | ||
assert(TethysBuilder(value) === LogTree(value).noSpaces) | ||
} | ||
} |