Skip to content

Commit 09727c2

Browse files
committed
Refactor: cleanup redundant test setup code
1 parent 4200c92 commit 09727c2

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

WordPress/src/test/java/org/wordpress/android/ui/uploads/UploadStarterTest.kt

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,10 @@ class UploadStarterTest : BaseUnitTest() {
195195

196196
@Test
197197
fun `when uploading all sites, posts & pages of the sites are uploaded`() {
198-
// Given
199-
val connectionStatus = createConnectionStatusLiveData(null)
200-
val uploadServiceFacade = createMockedUploadServiceFacade()
201-
val starter = createUploadStarter(connectionStatus, uploadServiceFacade)
198+
val starter = createUploadStarter()
202199

203-
// When
204200
starter.queueUploadFromAllSites()
205201

206-
// Then
207202
val expectedUploadPostExecutions = draftPosts.size + draftPages.size
208203
verify(uploadServiceFacade, times(expectedUploadPostExecutions)).uploadPost(
209204
context = any(),
@@ -213,19 +208,15 @@ class UploadStarterTest : BaseUnitTest() {
213208
}
214209

215210
@Test
216-
fun `given a failure, when uploading all sites, all other posts & pages are uploaded`() {
217-
// Given
218-
val connectionStatus = createConnectionStatusLiveData(null)
219-
val uploadServiceFacade = createMockedUploadServiceFacade()
220-
221-
val starter = createUploadStarter(connectionStatus, uploadServiceFacade)
222-
whenever(uploadServiceFacade.uploadPost(any(), eq(draftPosts.first()), any()))
223-
.thenThrow(CancellationException("fake upload error"))
211+
fun `given a failure, when uploading all sites, all other posts & pages are uploaded`() = test {
212+
val starter = createUploadStarter()
213+
draftPages.first().let {
214+
whenever(uploadServiceFacade.uploadPost(any(), eq(it), any()))
215+
.thenThrow(CancellationException("Upload error in test for post: " + it.title))
216+
}
224217

225-
// When
226218
starter.queueUploadFromAllSites()
227219

228-
// Then
229220
val expectedUploadPostExecutions = draftPosts.size + draftPages.size
230221
verify(uploadServiceFacade, times(expectedUploadPostExecutions)).uploadPost(
231222
context = any(),

0 commit comments

Comments
 (0)