Skip to content

Commit 15cf842

Browse files
Copilotndmanvar
andcommitted
Fix SentryCliVersionValueSource to use custom URL parameter and add tests
Co-authored-by: ndmanvar <314061+ndmanvar@users.noreply.github.com>
1 parent ded4497 commit 15cf842

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

plugin-build/src/main/kotlin/io/sentry/android/gradle/telemetry/SentryTelemetryService.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,11 @@ abstract class SentryCliVersionValueSource : ValueSource<String, VersionParams>
491491

492492
val args = mutableListOf(parameters.cliExecutable.get())
493493

494+
parameters.url.orNull?.let { url ->
495+
args.add("--url")
496+
args.add(url)
497+
}
498+
494499
args.add("--log-level=error")
495500
args.add("--version")
496501

plugin-build/src/test/kotlin/io/sentry/android/gradle/telemetry/SentryTelemetryServiceTest.kt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io.sentry.android.gradle.telemetry
22

33
import io.sentry.android.gradle.SentryCliProvider
44
import kotlin.test.assertEquals
5+
import kotlin.test.assertTrue
56
import org.gradle.testfixtures.ProjectBuilder
67
import org.junit.Rule
78
import 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

Comments
 (0)