Skip to content
This repository has been archived by the owner on Oct 22, 2023. It is now read-only.

Commit

Permalink
Add changes left out of previous commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskorn committed Nov 2, 2021
1 parent ba5bf8a commit 5772f60
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
1 change: 0 additions & 1 deletion app/src/main/kotlin/batect/Application.kt
Expand Up @@ -27,7 +27,6 @@ import batect.logging.logger
import batect.os.ConsoleManager
import batect.os.SystemInfo
import batect.telemetry.EnvironmentTelemetryCollector
import batect.telemetry.TelemetryConsentPrompt
import batect.telemetry.TelemetryManager
import batect.telemetry.TelemetrySessionBuilder
import batect.telemetry.addUnhandledExceptionEvent
Expand Down
Expand Up @@ -63,7 +63,6 @@ import org.mockito.kotlin.any
import org.mockito.kotlin.doAnswer
import org.mockito.kotlin.doThrow
import org.mockito.kotlin.mock
import org.mockito.kotlin.never
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever
import org.spekframework.spek2.Spek
Expand Down
Expand Up @@ -28,7 +28,7 @@ import java.util.UUID

object TelemetryConsentSpec : Spek({
describe("telemetry consent") {
data class TestCase(val disabledOnCommandLine: Boolean?, val consentStateOnDisk: ConsentState, val disabledForThisSession: Boolean, val expected: Boolean)
data class TestCase(val disabledOnCommandLine: Boolean?, val consentStateOnDisk: ConsentState, val forbiddenByProjectConfig: Boolean, val expected: Boolean)

setOf(
TestCase(true, ConsentState.TelemetryDisabled, false, expected = false),
Expand All @@ -49,7 +49,7 @@ object TelemetryConsentSpec : Spek({
TestCase(null, ConsentState.TelemetryDisabled, true, expected = false),
TestCase(null, ConsentState.TelemetryAllowed, true, expected = false),
TestCase(null, ConsentState.None, true, expected = false),
).forEach { (disabledOnCommandLine, consentStateOnDisk, disabledForThisSession, expected) ->
).forEach { (disabledOnCommandLine, consentStateOnDisk, forbiddenByProjectConfig, expected) ->
val commandLineDescription = when (disabledOnCommandLine) {
true -> "explicitly disabled on the command line"
false -> "explicitly enabled on the command line"
Expand All @@ -62,7 +62,7 @@ object TelemetryConsentSpec : Spek({
ConsentState.None -> "there is no configuration on disk"
}

val sessionDescription = if (disabledForThisSession) "disabled for this session" else "not disabled for this session"
val sessionDescription = if (forbiddenByProjectConfig) "forbidden by the project's configuration" else "not forbidden by the project's configuration"

val configurationStore by createForEachTest {
mock<TelemetryConfigurationStore> {
Expand All @@ -73,9 +73,7 @@ object TelemetryConsentSpec : Spek({
val consent by createForEachTest { TelemetryConsent(disabledOnCommandLine, configurationStore) }

beforeEachTest {
if (disabledForThisSession) {
consent.disableTelemetryForThisSession()
}
consent.forbiddenByProjectConfig = forbiddenByProjectConfig
}

given("telemetry is $commandLineDescription, $consentStateOnDiskDescription and $sessionDescription") {
Expand Down

0 comments on commit 5772f60

Please sign in to comment.