Skip to content

Commit a7be60d

Browse files
committed
added purge test
1 parent 7dbd75b commit a7be60d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,18 @@ class SentryExecutorServiceTest {
214214
repeat(1000) { sentryExecutor.schedule({}, TimeUnit.DAYS.toMillis(1)) }
215215
assertEquals(1000, executor.queue.size)
216216
}
217+
218+
@Test
219+
fun `SentryExecutorService purges cancelled jobs when limit is reached`() {
220+
val executor = ScheduledThreadPoolExecutor(1)
221+
val sentryExecutor = SentryExecutorService(executor, null)
222+
// Post 1k jobs after 1 day, to test they are all accepted
223+
repeat(1000) {
224+
val future = sentryExecutor.schedule({}, TimeUnit.DAYS.toMillis(1))
225+
future.cancel(true)
226+
}
227+
assertEquals(1000, executor.queue.size)
228+
sentryExecutor.submit { }
229+
assertEquals(1, executor.queue.size)
230+
}
217231
}

0 commit comments

Comments
 (0)