Skip to content

Commit 4b1e57e

Browse files
committed
update ratelimiter test to check for both profileChunk and profileChunkUi drops
1 parent a32b71e commit 4b1e57e

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

sentry/src/test/java/io/sentry/transport/RateLimiterTest.kt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ class RateLimiterTest {
456456
}
457457

458458
@Test
459-
fun `drop profileChunk items as lost`() {
459+
fun `drop profileChunkUi items as lost`() {
460460
val rateLimiter = fixture.getSUT()
461461

462462
val profileChunkItem = SentryEnvelopeItem.fromProfileChunk(ProfileChunk(), fixture.serializer)
@@ -481,6 +481,32 @@ class RateLimiterTest {
481481
verifyNoMoreInteractions(fixture.clientReportRecorder)
482482
}
483483

484+
@Test
485+
fun `drop profileChunk items as lost`() {
486+
val rateLimiter = fixture.getSUT()
487+
488+
val profileChunkItem = SentryEnvelopeItem.fromProfileChunk(ProfileChunk(), fixture.serializer)
489+
val attachmentItem =
490+
SentryEnvelopeItem.fromAttachment(
491+
fixture.serializer,
492+
NoOpLogger.getInstance(),
493+
Attachment("{ \"number\": 10 }".toByteArray(), "log.json"),
494+
1000,
495+
)
496+
val envelope =
497+
SentryEnvelope(SentryEnvelopeHeader(), arrayListOf(profileChunkItem, attachmentItem))
498+
499+
rateLimiter.updateRetryAfterLimits("60:profile_chunk:key", null, 1)
500+
val result = rateLimiter.filter(envelope, Hint())
501+
502+
assertNotNull(result)
503+
assertEquals(1, result.items.toList().size)
504+
505+
verify(fixture.clientReportRecorder, times(1))
506+
.recordLostEnvelopeItem(eq(DiscardReason.RATELIMIT_BACKOFF), same(profileChunkItem))
507+
verifyNoMoreInteractions(fixture.clientReportRecorder)
508+
}
509+
484510
@Test
485511
fun `drop feedback items as lost`() {
486512
val rateLimiter = fixture.getSUT()

0 commit comments

Comments
 (0)