diff options
author | Ivan Topolnak <ivantopo@gmail.com> | 2013-05-24 15:55:54 -0300 |
---|---|---|
committer | Ivan Topolnak <ivantopo@gmail.com> | 2013-05-24 15:55:54 -0300 |
commit | 00bc817f9dcebd1134d42308cf3a5f5ac7ef4185 (patch) | |
tree | d03448d3a5125bd234a823156b310da6aa0c9480 /src/test/scala/kamon | |
parent | c9ffaa39ac1cc64e635973f5b7a896a8c528c7bf (diff) | |
download | Kamon-00bc817f9dcebd1134d42308cf3a5f5ac7ef4185.tar.gz Kamon-00bc817f9dcebd1134d42308cf3a5f5ac7ef4185.tar.bz2 Kamon-00bc817f9dcebd1134d42308cf3a5f5ac7ef4185.zip |
Included test for cases in which TraceContext are not available at creation time
Diffstat (limited to 'src/test/scala/kamon')
-rw-r--r-- | src/test/scala/kamon/instrumentation/FutureInstrumentationSpec.scala | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/test/scala/kamon/instrumentation/FutureInstrumentationSpec.scala b/src/test/scala/kamon/instrumentation/FutureInstrumentationSpec.scala index 6f2a3678..713d1248 100644 --- a/src/test/scala/kamon/instrumentation/FutureInstrumentationSpec.scala +++ b/src/test/scala/kamon/instrumentation/FutureInstrumentationSpec.scala @@ -20,8 +20,7 @@ class FutureInstrumentationSpec extends WordSpec with MustMatchers with ScalaFut whenReady(futureWithContext) { result => result.value must be === testContext } - } - } + }} "should be available during the execution of onComplete callbacks" in { new FutureWithContext { val onCompleteContext = Promise[TraceContext]() @@ -33,19 +32,29 @@ class FutureInstrumentationSpec extends WordSpec with MustMatchers with ScalaFut whenReady(onCompleteContext.future) { result => result must be === testContext } - } - } + }} } } "created in a thread that doest have a TraceContext" must { - "not capture any TraceContext" in { new FutureWithoutContext{ + "not capture any TraceContext for the body execution" in { new FutureWithoutContext{ whenReady(futureWithoutContext) { result => result must be === None } + }} + + "not make any TraceContext available during the onComplete callback" in { new FutureWithoutContext { + val onCompleteContext = Promise[Option[TraceContext]]() + + futureWithoutContext.onComplete({ + case _ => onCompleteContext.complete(Success(TraceContext.current)) + }) + + whenReady(onCompleteContext.future) { result => + result must be === None } - } + }} } } @@ -60,7 +69,7 @@ class FutureInstrumentationSpec extends WordSpec with MustMatchers with ScalaFut } trait FutureWithoutContext { - TraceContext.clear + TraceContext.clear // Make sure no TraceContext is available val futureWithoutContext = Future { TraceContext.current } } } |