-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix misleading auth-token error message in case "sentry-cli info" fai…
…ls (#708) * Fix don't run cli if auth token is not present * Redirect sentry-cli info stderr * Update Changelog * Add test * Make ktlint happy * Fix tests
- Loading branch information
Showing
3 changed files
with
77 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...in-build/src/test/kotlin/io/sentry/android/gradle/telemetry/SentryTelemetryServiceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.sentry.android.gradle.telemetry | ||
|
||
import io.sentry.android.gradle.SentryCliProvider | ||
import kotlin.test.assertEquals | ||
import org.gradle.testfixtures.ProjectBuilder | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.rules.TemporaryFolder | ||
|
||
class SentryTelemetryServiceTest { | ||
|
||
@get:Rule | ||
val testProjectDir = TemporaryFolder() | ||
|
||
@Suppress("UnstableApiUsage") | ||
@Test | ||
fun `SentryCliInfoValueSource returns empty string when no auth token is present`() { | ||
val project = ProjectBuilder | ||
.builder() | ||
.withProjectDir(testProjectDir.root) | ||
.build() | ||
|
||
val cliPath = SentryCliProvider | ||
.getCliResourcesExtractionPath(project.layout.buildDirectory.asFile.get()) | ||
|
||
val infoOutput = project.providers.of(SentryCliInfoValueSource::class.java) { cliVS -> | ||
cliVS.parameters.buildDirectory.set(project.buildDir) | ||
cliVS.parameters.cliExecutable.set(cliPath.absolutePath) | ||
// sets an empty/invalid auth token | ||
cliVS.parameters.authToken.set("") | ||
}.get() | ||
|
||
assertEquals("", infoOutput) | ||
} | ||
} |