Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
- name: Run build debug
run: ./gradlew assembleDebug
- name: Run Tests
env:
CONFIDENCE_CLIENT_SECRET: ${{ secrets.CONFIDENCE_CLIENT_SECRET }}
run: ./gradlew :Provider:testDebugUnitTest --no-daemon --stacktrace --info
- name: Run build release
run: ./gradlew assembleRelease
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.Context
import com.spotify.confidence.cache.FileDiskStorage
import com.spotify.confidence.client.ResolvedFlag
import org.junit.Assert
import org.junit.Assume
import org.junit.Before
import org.junit.Rule
import org.junit.Test
Expand All @@ -15,7 +16,7 @@ import org.mockito.kotlin.whenever
import java.nio.file.Files
import java.util.UUID

private const val clientSecret = "21wxcxXpU6tKBRFtEFTXYiH7nDqL86Mm"
private val clientSecret = System.getenv("CONFIDENCE_CLIENT_SECRET") ?: ""
private val mockContext: Context = mock()

class ConfidenceIntegrationTests {
Expand All @@ -25,6 +26,7 @@ class ConfidenceIntegrationTests {

@Before
fun setup() {
Assume.assumeTrue("CONFIDENCE_CLIENT_SECRET not set, skipping integration tests", clientSecret.isNotEmpty())
whenever(mockContext.filesDir).thenReturn(Files.createTempDirectory("tmpTests").toFile())
whenever(mockContext.getDir(any(), any())).thenReturn(Files.createTempDirectory("events").toFile())
whenever(mockContext.getSharedPreferences(SHARED_PREFS_NAME, Context.MODE_PRIVATE)).thenReturn(InMemorySharedPreferences())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.advanceUntilIdle
import kotlinx.coroutines.test.runTest
import org.junit.Assert
import org.junit.Assume
import org.junit.Before
import org.junit.Test
import org.mockito.kotlin.any
Expand All @@ -19,7 +20,7 @@ import org.mockito.kotlin.whenever
import java.io.File
import java.nio.file.Files

private const val clientSecret = "WciJVLIEiNnRxV8gaYPZNCFF8vbAXOu6"
private val clientSecret = System.getenv("CONFIDENCE_CLIENT_SECRET") ?: ""
private val mockContext: Context = mock()
private val mockSharedPrefs: SharedPreferences = mock()
private val mockSharedPrefsEdit: SharedPreferences.Editor = mock()
Expand All @@ -32,6 +33,7 @@ class EventSenderIntegrationTest {

@Before
fun setup() {
Assume.assumeTrue("CONFIDENCE_CLIENT_SECRET not set, skipping integration tests", clientSecret.isNotEmpty())
whenever(mockContext.getDir("events", Context.MODE_PRIVATE)).thenReturn(directory)
whenever(mockContext.getSharedPreferences(SHARED_PREFS_NAME, Context.MODE_PRIVATE)).thenReturn(mockSharedPrefs)
whenever(mockSharedPrefs.edit()).thenReturn(mockSharedPrefsEdit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.junit.Assert.assertNotEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Assume
import org.junit.Before
import org.junit.Rule
import org.junit.Test
Expand All @@ -41,7 +42,7 @@ import java.io.File
import java.nio.file.Files
import java.util.UUID

private const val clientSecret = "21wxcxXpU6tKBRFtEFTXYiH7nDqL86Mm"
private val clientSecret = System.getenv("CONFIDENCE_CLIENT_SECRET") ?: ""
private val mockContext: Context = mock()

class ProviderIntegrationTest {
Expand All @@ -53,6 +54,7 @@ class ProviderIntegrationTest {

@Before
fun setup() = runTest(UnconfinedTestDispatcher()) {
Assume.assumeTrue("CONFIDENCE_CLIENT_SECRET not set, skipping integration tests", clientSecret.isNotEmpty())
mockkStatic(Log::class)
every { Log.d(any(), any()) } answers {
println("DEBUG: ${arg<String>(1)}")
Expand Down
Loading