-
-
Notifications
You must be signed in to change notification settings - Fork 468
Expand file tree
/
Copy pathSpotlightIntegrationTest.kt
More file actions
74 lines (58 loc) · 2.28 KB
/
SpotlightIntegrationTest.kt
File metadata and controls
74 lines (58 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package io.sentry.spotlight
import io.sentry.IScopes
import io.sentry.SentryOptions
import io.sentry.SentryOptions.BeforeEnvelopeCallback
import io.sentry.util.SpotlightPlatformTestManipulator
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNull
import org.mockito.kotlin.mock
class SpotlightIntegrationTest {
@Test
fun `Integration does not register before-envelope callback when disabled`() {
val options = SentryOptions().apply { isEnableSpotlight = false }
val spotlight = SpotlightIntegration()
spotlight.register(mock<IScopes>(), options)
assertNull(options.beforeEnvelopeCallback)
}
@Test
fun `Integration does not register before-envelope callback when before-envelope is already set`() {
val envelopeCallback = mock<BeforeEnvelopeCallback>()
val options =
SentryOptions().apply {
isEnableSpotlight = true
beforeEnvelopeCallback = envelopeCallback
}
val spotlight = SpotlightIntegration()
spotlight.register(mock<IScopes>(), options)
assertEquals(envelopeCallback, options.beforeEnvelopeCallback)
}
@Test
fun `Integration does register and un-register before-envelope callback`() {
val options = SentryOptions().apply { isEnableSpotlight = true }
val spotlight = SpotlightIntegration()
spotlight.register(mock<IScopes>(), options)
assertEquals(options.beforeEnvelopeCallback, spotlight)
spotlight.close()
assertNull(options.beforeEnvelopeCallback)
}
@Test
fun `spotlight connection url falls back to platform defaults`() {
val spotlight = SpotlightIntegration()
SpotlightPlatformTestManipulator.pretendIsAndroid(true)
assertEquals("http://10.0.2.2:8969/stream", spotlight.spotlightConnectionUrl)
SpotlightPlatformTestManipulator.pretendIsAndroid(false)
assertEquals("http://localhost:8969/stream", spotlight.spotlightConnectionUrl)
}
@Test
fun `respects spotlight connection url set via options`() {
val options =
SentryOptions().apply {
isEnableSpotlight = true
spotlightConnectionUrl = "http://example.com:1234/stream"
}
val spotlight = SpotlightIntegration()
spotlight.register(mock<IScopes>(), options)
assertEquals("http://example.com:1234/stream", spotlight.spotlightConnectionUrl)
}
}