From 0bce1b24c3a75c28d125fe7d91d05ea1f28926d5 Mon Sep 17 00:00:00 2001 From: Ivan Topolnjak Date: Mon, 17 Jul 2017 14:26:30 +0200 Subject: add test case for decoding a invalid identifier --- .../test/scala/kamon/trace/DefaultIdentityGeneratorSpec.scala | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'kamon-core/src/test/scala/kamon') diff --git a/kamon-core/src/test/scala/kamon/trace/DefaultIdentityGeneratorSpec.scala b/kamon-core/src/test/scala/kamon/trace/DefaultIdentityGeneratorSpec.scala index bbd04df1..8977e3cd 100644 --- a/kamon-core/src/test/scala/kamon/trace/DefaultIdentityGeneratorSpec.scala +++ b/kamon-core/src/test/scala/kamon/trace/DefaultIdentityGeneratorSpec.scala @@ -14,7 +14,7 @@ class DefaultIdentityGeneratorSpec extends WordSpecLike with Matchers with Optio def validateGenerator(generatorName: String, generator: IdentityProvider.Generator) = { s"The $generatorName" should { - "generate random longs (8 byte) as Span and Trace identifiers" in { + "generate random longs (8 byte) identifiers" in { 100 times { val Identifier(string, bytes) = generator.generate() @@ -38,9 +38,15 @@ class DefaultIdentityGeneratorSpec extends WordSpecLike with Matchers with Optio val identifier = generator.generate() val decodedIdentifier = generator.from(identifier.bytes) - identifier should equal(decodedIdentifier) + identifier.string should equal(decodedIdentifier.string) + identifier.bytes should equal(decodedIdentifier.bytes) } } + + "return IdentityProvider.NoIdentifier if the provided input cannot be decoded into a Identifier" in { + generator.from("zzzz") shouldBe(IdentityProvider.NoIdentifier) + generator.from(Array[Byte](1)) shouldBe(IdentityProvider.NoIdentifier) + } } } } -- cgit v1.2.3