@@ -113,11 +113,13 @@ class PreviousSessionFinalizerTest {
113113
114114 @Test
115115 fun `if previous session exists, sends session update with current end time` () {
116- // we start the session 20 seconds before now, this should create enough distance to the current
117- // DateTime to detect an update
118- val sessionCreationCaptureInterval = 20000
116+ // we start the session 20 seconds before _now_. This should create enough distance to the
117+ // capture timestamp to stably detect an update from inside the captureEvent mock.
118+ val sessionCreationToFinalizerInterval = 20000
119119 val sessionCreationTimestamp =
120- DateUtils .getDateTime(DateUtils .getCurrentDateTime().time - sessionCreationCaptureInterval)
120+ DateUtils .getDateTime(
121+ DateUtils .getCurrentDateTime().time - sessionCreationToFinalizerInterval
122+ )
121123
122124 val finalizer =
123125 fixture.getSut(
@@ -145,13 +147,13 @@ class PreviousSessionFinalizerTest {
145147 verify(fixture.scopes)
146148 .captureEnvelope(
147149 argThat {
148- val captureEnvelopeTimestamp = DateUtils .getCurrentDateTime().time
150+ val captureTimestamp = DateUtils .getCurrentDateTime().time
149151 val session = fixture.sessionFromEnvelope(this )
150152 session.release == " io.sentry.sample@1.0" &&
151153 session.started!! .time == sessionCreationTimestamp.time &&
152- captureEnvelopeTimestamp - session.started!! .time > sessionCreationCaptureInterval &&
154+ captureTimestamp - session.started!! .time > sessionCreationToFinalizerInterval &&
153155 session.timestamp!! .time != sessionCreationTimestamp.time &&
154- captureEnvelopeTimestamp - session.timestamp!! .time < 1000
156+ captureTimestamp - session.timestamp!! .time < 1000
155157 }
156158 )
157159 }
0 commit comments