Skip to content

Commit f778ca4

Browse files
committed
add test
1 parent cc637d4 commit f778ca4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

sentry/src/test/java/io/sentry/util/TracingUtilsTest.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,22 @@ class TracingUtilsTest {
7979
assertFalse(fixture.scope.propagationContext.baggage!!.isMutable)
8080
}
8181

82+
@Test
83+
fun `returns headers if allowed from scope if span is noop sampled=null`() {
84+
fixture.setup()
85+
fixture.scope.propagationContext.isSampled = null
86+
87+
val headers = TracingUtils.traceIfAllowed(fixture.scopes, "https://sentry.io/hello", fixture.preExistingBaggage, NoOpSpan.getInstance())
88+
89+
assertNotNull(headers)
90+
assertNotNull(headers.baggageHeader)
91+
assertEquals(fixture.scope.propagationContext.spanId, headers.sentryTraceHeader.spanId)
92+
assertEquals(fixture.scope.propagationContext.traceId, headers.sentryTraceHeader.traceId)
93+
assertEquals(fixture.scope.propagationContext.isSampled, headers.sentryTraceHeader.isSampled)
94+
assertTrue(headers.baggageHeader!!.value.contains("some-baggage-key=some-baggage-value"))
95+
assertFalse(fixture.scope.propagationContext.baggage!!.isMutable)
96+
}
97+
8298
@Test
8399
fun `returns headers if allowed from scope if span is noop sampled=true`() {
84100
fixture.setup()

0 commit comments

Comments
 (0)