Skip to content

Commit

Permalink
chore: minor test clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-fiedler committed Mar 20, 2024
1 parent b0954dd commit e174ca6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.app.Application
import android.content.Context
import android.net.ConnectivityManager
import com.amplitude.android.plugins.AndroidLifecyclePlugin
import com.amplitude.android.utilities.SystemTime
import com.amplitude.android.utils.mockSystemTime
import com.amplitude.common.android.AndroidContextProvider
import com.amplitude.core.Storage
Expand Down Expand Up @@ -638,7 +637,7 @@ class AmplitudeSessionTest {
val startTime: Long = 1000
var time: Long = startTime

every { SystemTime.getCurrentTimeMillis() } returns time
mockSystemTime(time)

val storageProvider = InstanceStorageProvider(InMemoryStorage())
val config = createConfiguration(storageProvider)
Expand Down Expand Up @@ -682,7 +681,7 @@ class AmplitudeSessionTest {
time += config.minTimeBetweenSessionsMillis + 100

// Mock starting in foreground
every { SystemTime.getCurrentTimeMillis() } returns time
mockSystemTime(time)

// Create a new instance to simulate recreation at startup in foreground
val amplitude2 = Amplitude(createConfiguration(storageProvider))
Expand Down
6 changes: 2 additions & 4 deletions android/src/test/java/com/amplitude/android/AmplitudeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.net.ConnectivityManager
import com.amplitude.analytics.connector.AnalyticsConnector
import com.amplitude.analytics.connector.Identity
import com.amplitude.android.plugins.AndroidLifecyclePlugin
import com.amplitude.android.utilities.SystemTime
import com.amplitude.android.utils.mockSystemTime
import com.amplitude.common.android.AndroidContextProvider
import com.amplitude.core.StorageProvider
import com.amplitude.core.events.BaseEvent
Expand All @@ -18,7 +18,6 @@ import com.amplitude.id.IMIdentityStorageProvider
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkConstructor
import io.mockk.mockkObject
import io.mockk.mockkStatic
import io.mockk.slot
import io.mockk.spyk
Expand Down Expand Up @@ -221,8 +220,7 @@ class AmplitudeTest {
@Test
fun amplitude_getSessionId_should_be_the_current_time_after_isBuilt() = runTest {
val time = 1000L
mockkObject(SystemTime)
every { SystemTime.getCurrentTimeMillis() } returns time
mockSystemTime(time)

amplitude = Amplitude(createConfiguration())

Expand Down

0 comments on commit e174ca6

Please sign in to comment.