-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(storage): Fix multiple instances of TransferDB leading to SQLiteD…
…atabaseLockedException (#2786) Co-authored-by: Tyler Roach <[email protected]>
- Loading branch information
1 parent
916a3bb
commit c6e9e91
Showing
6 changed files
with
55 additions
and
30 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
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
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
28 changes: 28 additions & 0 deletions
28
aws-storage-s3/src/test/java/com/amplifyframework/storage/s3/transfer/TransferDBTest.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,28 @@ | ||
package com.amplifyframework.storage.s3.transfer | ||
|
||
import io.kotest.matchers.types.shouldBeSameInstanceAs | ||
import org.junit.After | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
import org.robolectric.RuntimeEnvironment | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
class TransferDBTest { | ||
|
||
@After | ||
fun teardown() { | ||
// Clear instance | ||
TransferDB.instance = null | ||
} | ||
|
||
@Test | ||
fun `getInstance returns the same object`() { | ||
val context = RuntimeEnvironment.getApplication() | ||
|
||
val db1 = TransferDB.getInstance(context) | ||
val db2 = TransferDB.getInstance(context) | ||
|
||
db1 shouldBeSameInstanceAs db2 | ||
} | ||
} |