File tree Expand file tree Collapse file tree 4 files changed +28
-6
lines changed
src/main/java/com/duckduckgo/app/tabs/ui
main/java/com/duckduckgo/pir/impl/brokers
test/kotlin/com/duckduckgo/pir/impl/brokers Expand file tree Collapse file tree 4 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -442,13 +442,15 @@ class TabSwitcherAdapter(
442442 if (holder is TabSwitcherViewHolder ) {
443443 holder.cancelLoadJobs()
444444 }
445+
446+ val glide = Glide .with (holder.itemView.context.applicationContext)
445447 when (holder) {
446448 is TabSwitcherViewHolder .GridTabViewHolder -> {
447- Glide . with (holder.rootView) .clear(holder.tabPreview)
448- Glide . with (holder.rootView) .clear(holder.favicon)
449+ glide .clear(holder.tabPreview)
450+ glide .clear(holder.favicon)
449451 }
450452 is TabSwitcherViewHolder .ListTabViewHolder -> {
451- Glide . with (holder.rootView) .clear(holder.favicon)
453+ glide .clear(holder.favicon)
452454 }
453455 }
454456 }
Original file line number Diff line number Diff line change 1- VERSION =5.270.0
1+ VERSION =5.270.1
Original file line number Diff line number Diff line change @@ -110,13 +110,13 @@ class RealBrokerJsonUpdater @Inject constructor(
110110
111111 val updatedJsons = jsonEtagsFromConfig.toSet() - existingEtags.toSet()
112112
113- pirRepository.updateBrokerJsons(jsonEtagsFromConfig)
114-
115113 if (updatedJsons.isNotEmpty()) {
116114 logcat { " PIR-update: Downloading updated broker json files: $updatedJsons " }
117115 brokerDataDownloader.downloadBrokerData(updatedJsons.map { it.fileName })
118116 } else {
119117 logcat { " PIR-update: No broker json files to update." }
120118 }
119+
120+ pirRepository.updateBrokerJsons(jsonEtagsFromConfig)
121121 }
122122}
Original file line number Diff line number Diff line change @@ -273,4 +273,24 @@ class RealBrokerJsonUpdaterTest {
273273 verify(mockPirRepository, never()).updateMainEtag(any())
274274 verify(mockPirRepository, never()).updateBrokerJsons(any())
275275 }
276+
277+ @Test
278+ fun whenDownloadBrokerDataThrowsExceptionThenBrokerJsonsNotUpdated () = runTest {
279+ // Given
280+ val successResponse = Response .success(testMainConfig)
281+ whenever(mockPirRepository.getCurrentMainEtag()).thenReturn(" old-etag" )
282+ whenever(mockPirRepository.getStoredBrokersCount()).thenReturn(2 )
283+ whenever(mockDbpService.getMainConfig(" old-etag" )).thenReturn(successResponse)
284+ whenever(mockPirRepository.getAllLocalBrokerJsons()).thenReturn(testExistingBrokerJsons)
285+ whenever(mockBrokerDataDownloader.downloadBrokerData(any())).thenThrow(RuntimeException (" Download failed" ))
286+
287+ // When
288+ val result = testee.update()
289+
290+ // Then - etags should NOT be saved when download fails
291+ assertFalse(result)
292+ verify(mockBrokerDataDownloader).downloadBrokerData(listOf (testFileName2, testFileName3))
293+ verify(mockPirRepository, never()).updateBrokerJsons(any())
294+ verify(mockPirRepository, never()).updateMainEtag(any())
295+ }
276296}
You can’t perform that action at this time.
0 commit comments