Skip to content

Commit 85c6d6f

Browse files
committed
attempt to fix test on CI
1 parent b7ef242 commit 85c6d6f

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

aws-storage-s3/src/test/java/com/amplifyframework/storage/s3/AWSS3StoragePluginTest.kt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
package com.amplifyframework.storage.s3
1717

18+
import android.content.Context
19+
import androidx.test.core.app.ApplicationProvider
1820
import com.amplifyframework.storage.BucketInfo
1921
import com.amplifyframework.storage.InvalidStorageBucketException
2022
import com.amplifyframework.storage.StorageBucket
@@ -32,9 +34,13 @@ import org.junit.Test
3234
import org.junit.runner.RunWith
3335
import org.robolectric.RobolectricTestRunner
3436

37+
3538
@RunWith(RobolectricTestRunner::class)
3639
class AWSS3StoragePluginTest {
3740

41+
var context: Context = ApplicationProvider.getApplicationContext()
42+
43+
3844
private val storageServiceFactory = mockk<AWSS3StorageService.Factory> {
3945
every { create(any(), any(), any(), any(), any()) } returns mockk<AWSS3StorageService>()
4046
}
@@ -54,7 +60,7 @@ class AWSS3StoragePluginTest {
5460
}
5561
}
5662

57-
plugin.configure(data, mockk(relaxed = true))
63+
plugin.configure(data, context)
5864

5965
verify {
6066
storageServiceFactory.create(any(), "test-region", "test-bucket", any(), any())
@@ -68,7 +74,7 @@ class AWSS3StoragePluginTest {
6874
}
6975

7076
shouldThrow<StorageException> {
71-
plugin.configure(data, mockk(relaxed = true))
77+
plugin.configure(data, context)
7278
}
7379
}
7480

@@ -86,7 +92,7 @@ class AWSS3StoragePluginTest {
8692
}
8793
}
8894

89-
plugin.configure(data, mockk(relaxed = true))
95+
plugin.configure(data, context)
9096
val service = plugin.getStorageService(null)
9197
service shouldNotBe null
9298
}
@@ -105,7 +111,7 @@ class AWSS3StoragePluginTest {
105111
}
106112
}
107113

108-
plugin.configure(data, mockk(relaxed = true))
114+
plugin.configure(data, context)
109115
val bucketInfo = BucketInfo("test-bucket", "test-region")
110116
val bucket = StorageBucket.fromBucketInfo(bucketInfo)
111117
val service = plugin.getStorageService(bucket)
@@ -126,7 +132,7 @@ class AWSS3StoragePluginTest {
126132
}
127133
}
128134

129-
plugin.configure(data, mockk(relaxed = true))
135+
plugin.configure(data, context)
130136
val bucket = StorageBucket.fromOutputs("test=name")
131137
val service = plugin.getStorageService(bucket)
132138
service shouldNotBe null
@@ -146,7 +152,7 @@ class AWSS3StoragePluginTest {
146152
}
147153
}
148154

149-
plugin.configure(data, mockk(relaxed = true))
155+
plugin.configure(data, context)
150156
val bucket = StorageBucket.fromOutputs("myBucket")
151157
val exception = shouldThrow<StorageException> {
152158
plugin.getStorageService(bucket)
@@ -168,7 +174,7 @@ class AWSS3StoragePluginTest {
168174
}
169175
}
170176

171-
plugin.configure(data, mockk(relaxed = true))
177+
plugin.configure(data, context)
172178
val bucket = StorageBucket.fromOutputs("test-name")
173179
val result = plugin.getStorageServiceResult(bucket)
174180
val service = result.storageService
@@ -191,7 +197,7 @@ class AWSS3StoragePluginTest {
191197
}
192198
}
193199

194-
plugin.configure(data, mockk(relaxed = true))
200+
plugin.configure(data, context)
195201
val bucket = StorageBucket.fromOutputs("myBucket")
196202
val exception = plugin.getStorageServiceResult(bucket).storageException
197203
exception shouldNotBe null

0 commit comments

Comments
 (0)