@@ -2,6 +2,7 @@ package io.sentry.android.gradle.telemetry
22
33import io.sentry.android.gradle.SentryCliProvider
44import kotlin.test.assertEquals
5+ import kotlin.test.assertTrue
56import org.gradle.testfixtures.ProjectBuilder
67import org.junit.Rule
78import org.junit.Test
@@ -31,4 +32,47 @@ class SentryTelemetryServiceTest {
3132
3233 assertEquals(" " , infoOutput)
3334 }
35+
36+ @Suppress(" UnstableApiUsage" )
37+ @Test
38+ fun `SentryCliVersionValueSource returns version without custom URL` () {
39+ val project = ProjectBuilder .builder().withProjectDir(testProjectDir.root).build()
40+
41+ val cliPath =
42+ SentryCliProvider .getCliResourcesExtractionPath(project.layout.buildDirectory.asFile.get())
43+
44+ val versionOutput =
45+ project.providers
46+ .of(SentryCliVersionValueSource ::class .java) { cliVS ->
47+ cliVS.parameters.buildDirectory.set(project.buildDir)
48+ cliVS.parameters.cliExecutable.set(cliPath.absolutePath)
49+ // No URL set - should use default Sentry SAAS
50+ }
51+ .get()
52+
53+ // Version output should contain sentry-cli version
54+ assertTrue(versionOutput.isNotEmpty(), " Version output should not be empty" )
55+ }
56+
57+ @Suppress(" UnstableApiUsage" )
58+ @Test
59+ fun `SentryCliVersionValueSource works with custom URL` () {
60+ val project = ProjectBuilder .builder().withProjectDir(testProjectDir.root).build()
61+
62+ val cliPath =
63+ SentryCliProvider .getCliResourcesExtractionPath(project.layout.buildDirectory.asFile.get())
64+
65+ val versionOutput =
66+ project.providers
67+ .of(SentryCliVersionValueSource ::class .java) { cliVS ->
68+ cliVS.parameters.buildDirectory.set(project.buildDir)
69+ cliVS.parameters.cliExecutable.set(cliPath.absolutePath)
70+ // Set a custom URL for self-hosted Sentry
71+ cliVS.parameters.url.set(" https://sentry.example.com" )
72+ }
73+ .get()
74+
75+ // Version output should contain sentry-cli version
76+ assertTrue(versionOutput.isNotEmpty(), " Version output should not be empty" )
77+ }
3478}
0 commit comments