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
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import io.mockk.slot
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.runTest
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Before
Expand Down Expand Up @@ -93,6 +94,11 @@ internal class CloudWatchLogManagerTest {
)
}

@After
fun cleanup() {
WorkManagerTestInitHelper.closeWorkDatabase()
}

@Test
fun `on saveLogEvents and cache not full`() = runTest {
val cloudwatchEvent = CloudWatchLogEvent(System.currentTimeMillis(), "Sample log")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import io.mockk.every
import io.mockk.mockk
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -46,6 +47,11 @@ internal class LoggingConstraintsResolverTest {
private lateinit var loggingConstraintsResolver: LoggingConstraintsResolver
private val userId = "USER_ID"

@After
fun cleanup() {
WorkManagerTestInitHelper.closeWorkDatabase()
}

@Test
fun `test default logLevel`() {
val loggingConstraintsResolver = LoggingConstraintsResolver()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,21 @@
*/
package com.amplifyframework.storage.s3.transfer.worker

import androidx.work.impl.utils.SerialExecutor
import androidx.work.impl.utils.SynchronousExecutor
import androidx.work.impl.utils.taskexecutor.SerialExecutor
import androidx.work.impl.utils.taskexecutor.TaskExecutor
import java.util.concurrent.Executor

class ImmediateTaskExecutor : TaskExecutor {
private val mSynchronousExecutor: Executor = SynchronousExecutor()
private val mSerialExecutor = SerialExecutor(mSynchronousExecutor)
override fun postToMainThread(runnable: Runnable?) {
runnable?.run()
}
private val mSerialExecutor = SerialExecutorImpl(mSynchronousExecutor)

override fun getMainThreadExecutor(): Executor = mSynchronousExecutor

override fun executeOnBackgroundThread(runnable: Runnable?) {
runnable?.let { mSerialExecutor.execute(it) }
}
override fun getSerialTaskExecutor(): SerialExecutor = mSerialExecutor

override fun getBackgroundExecutor(): SerialExecutor = mSerialExecutor
private class SerialExecutorImpl(val delegate: Executor) : SerialExecutor, Executor by delegate {
// There's never any pending tasks since we execute all immediately
override fun hasPendingTasks() = false
}
}
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ androidx-test-core = "1.3.0"
androidx-test-junit = "1.1.2"
androidx-test-orchestrator = "1.4.2"
androidx-test-runner = "1.3.0"
androidx-workmanager = "2.7.1"
androidx-workmanager = "2.9.1"
apollo = "4.0.0"
aws-kotlin = "1.3.81" # ensure proper aws-smithy version also set
aws-sdk = "2.62.2"
Expand Down Expand Up @@ -74,7 +74,7 @@ androidx-nav-ui = { module = "androidx.navigation:navigation-ui", version.ref =
androidx-security = { module = "androidx.security:security-crypto", version.ref = "androidx-security" }
androidx-sqlite = { module = "androidx.sqlite:sqlite", version.ref = "androidx-sqlite" }
androidx-v4support = { module = "androidx.legacy:legacy-support-v4", version.ref = "androidx-legacy" }
androidx-workmanager = { module = "androidx.work:work-runtime-ktx", version.ref = "androidx-workmanager" }
androidx-workmanager = { module = "androidx.work:work-runtime", version.ref = "androidx-workmanager" }
apollo-runtime = { module = "com.apollographql.apollo:apollo-runtime", version.ref = "apollo" }
aws-cloudwatchlogs = { module = "aws.sdk.kotlin:cloudwatchlogs", version.ref = "aws-kotlin" }
aws-cognitoidentity = { module = "aws.sdk.kotlin:cognitoidentity", version.ref = "aws-kotlin" }
Expand Down