Skip to content

Commit 8fa62bb

Browse files
committed
Add tests for breadcrumbs and attachments via hints
1 parent 26e3bbc commit 8fa62bb

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

sentry/src/test/java/io/sentry/SentryClientTest.kt

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,40 @@ class SentryClientTest {
17881788

17891789
thenEnvelopeIsSentWith(0, 0, 1, 1)
17901790
}
1791-
// TODO breadcrumb test
1791+
1792+
@Test
1793+
fun `passing attachments via hint into breadcrumb ignores them`() {
1794+
val sut = fixture.getSut { options ->
1795+
options.setBeforeBreadcrumb { breadcrumb, hints ->
1796+
breadcrumb
1797+
}
1798+
}
1799+
1800+
val scope = givenScopeWithStartedSession()
1801+
scope.addBreadcrumb(Breadcrumb.info("hello from breadcrumb"), Hints.withAttachment(fixture.attachment))
1802+
1803+
sut.captureException(IllegalStateException(), scope)
1804+
1805+
thenEnvelopeIsSentWith(1, 1, 0)
1806+
}
1807+
1808+
@Test
1809+
fun `adding attachments in beforeBreadcrumb ignores them`() {
1810+
val sut = fixture.getSut { options ->
1811+
options.setBeforeBreadcrumb { breadcrumb, hints ->
1812+
hints.attachmentContainer.add(fixture.attachment)
1813+
breadcrumb
1814+
}
1815+
}
1816+
1817+
val scope = givenScopeWithStartedSession()
1818+
scope.addBreadcrumb(Breadcrumb.info("hello from breadcrumb"))
1819+
1820+
sut.captureException(IllegalStateException(), scope)
1821+
1822+
thenEnvelopeIsSentWith(1, 1, 0)
1823+
}
1824+
17921825
private fun givenScopeWithStartedSession(errored: Boolean = false, crashed: Boolean = false): Scope {
17931826
val scope = createScope(fixture.sentryOptions)
17941827
scope.startSession()

0 commit comments

Comments
 (0)