@@ -14,7 +14,9 @@ import io.sentry.hints.Cached
1414import io.sentry.hints.DiskFlushNotification
1515import io.sentry.hints.TransactionEnd
1616import io.sentry.logger.ILoggerBatchProcessor
17+ import io.sentry.logger.ILoggerBatchProcessorFactory
1718import io.sentry.metrics.IMetricsBatchProcessor
19+ import io.sentry.metrics.IMetricsBatchProcessorFactory
1820import io.sentry.protocol.Contexts
1921import io.sentry.protocol.Feedback
2022import io.sentry.protocol.Mechanism
@@ -78,6 +80,10 @@ class SentryClientTest {
7880 class Fixture {
7981 var transport = mock<ITransport >()
8082 var factory = mock<ITransportFactory >()
83+ var loggerBatchProcessor = mock<ILoggerBatchProcessor >()
84+ var loggerBatchProcessorFactory = mock<ILoggerBatchProcessorFactory >()
85+ var metricsBatchProcessor = mock<IMetricsBatchProcessor >()
86+ var metricsBatchProcessorFactory = mock<IMetricsBatchProcessorFactory >()
8187 val maxAttachmentSize: Long = (5 * 1024 * 1024 ).toLong()
8288 val scopes = mock<IScopes >()
8389 val sentryTracer: SentryTracer
@@ -94,12 +100,16 @@ class SentryClientTest {
94100 setLogger(mock())
95101 maxAttachmentSize = this @Fixture.maxAttachmentSize
96102 setTransportFactory(factory)
103+ logs.setLoggerBatchProcessorFactory(loggerBatchProcessorFactory)
104+ metrics.setMetricsBatchProcessorFactory(metricsBatchProcessorFactory)
97105 release = " 0.0.1"
98106 isTraceSampling = true
99107 }
100108
101109 init {
102110 whenever(factory.create(any(), any())).thenReturn(transport)
111+ whenever(loggerBatchProcessorFactory.create(any(), any())).thenReturn(loggerBatchProcessor)
112+ whenever(metricsBatchProcessorFactory.create(any(), any())).thenReturn(metricsBatchProcessor)
103113 whenever(scopes.options).thenReturn(sentryOptions)
104114 sentryTracer =
105115 SentryTracer (
@@ -168,21 +178,29 @@ class SentryClientTest {
168178
169179 @Test
170180 fun `when client is closed with isRestarting false, transport waits` () {
171- val sut = fixture.getSut()
181+ val sut = fixture.getSut { options -> options.logs.isEnabled = true }
172182 assertTrue(sut.isEnabled)
173183 sut.close(false )
174184 assertNotEquals(0 , fixture.sentryOptions.shutdownTimeoutMillis)
175185 verify(fixture.transport).flush(eq(fixture.sentryOptions.shutdownTimeoutMillis))
186+ verify(fixture.loggerBatchProcessor).flush(eq(fixture.sentryOptions.shutdownTimeoutMillis))
187+ verify(fixture.metricsBatchProcessor).flush(eq(fixture.sentryOptions.shutdownTimeoutMillis))
176188 verify(fixture.transport).close(eq(false ))
189+ verify(fixture.loggerBatchProcessor).close(eq(false ))
190+ verify(fixture.metricsBatchProcessor).close(eq(false ))
177191 }
178192
179193 @Test
180194 fun `when client is closed with isRestarting true, transport does not wait` () {
181- val sut = fixture.getSut()
195+ val sut = fixture.getSut { options -> options.logs.isEnabled = true }
182196 assertTrue(sut.isEnabled)
183197 sut.close(true )
184198 verify(fixture.transport).flush(eq(0 ))
199+ verify(fixture.loggerBatchProcessor).flush(eq(0 ))
200+ verify(fixture.metricsBatchProcessor).flush(eq(0 ))
185201 verify(fixture.transport).close(eq(true ))
202+ verify(fixture.loggerBatchProcessor).close(eq(true ))
203+ verify(fixture.metricsBatchProcessor).close(eq(true ))
186204 }
187205
188206 @Test
0 commit comments