From 784a0211aaddccc3ce22287cac3f8927c6463268 Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Fri, 24 Nov 2023 14:52:41 +0100 Subject: [PATCH] feat: do not stop FlushManager on successful flush If stored queue will be empty, on next execution of `FlushQueue`, the manager will be stopped anyway. https://github.com/Parsely/parsely-android/pull/92#discussion_r1400718192 --- .../com/parsely/parselyandroid/FlushQueue.kt | 4 --- .../parsely/parselyandroid/FlushQueueTest.kt | 26 ------------------- 2 files changed, 30 deletions(-) diff --git a/parsely/src/main/java/com/parsely/parselyandroid/FlushQueue.kt b/parsely/src/main/java/com/parsely/parselyandroid/FlushQueue.kt index b5864e91..4a989b95 100644 --- a/parsely/src/main/java/com/parsely/parselyandroid/FlushQueue.kt +++ b/parsely/src/main/java/com/parsely/parselyandroid/FlushQueue.kt @@ -39,10 +39,6 @@ internal class FlushQueue( onSuccess = { ParselyTracker.PLog("Pixel request success") repository.remove(eventsToSend) - ParselyTracker.PLog("Event queue empty, flush timer cleared.") - if (repository.getStoredQueue().isEmpty()) { - flushManager.stop() - } }, onFailure = { ParselyTracker.PLog("Pixel request exception") diff --git a/parsely/src/test/java/com/parsely/parselyandroid/FlushQueueTest.kt b/parsely/src/test/java/com/parsely/parselyandroid/FlushQueueTest.kt index d92c5705..e49605b6 100644 --- a/parsely/src/test/java/com/parsely/parselyandroid/FlushQueueTest.kt +++ b/parsely/src/test/java/com/parsely/parselyandroid/FlushQueueTest.kt @@ -103,32 +103,6 @@ class FlushQueueTest { assertThat(repository.getStoredQueue()).isNotEmpty } - @Test - fun `given non-empty local storage, when flushing queue with not skipping sending events, then flush manager is stopped`() = - runTest { - // given - val flushManager = FakeFlushManager() - val repository = FakeRepository().apply { - insertEvents(listOf(mapOf("test" to 123))) - } - val parselyAPIConnection = FakeRestClient().apply { - nextResult = Result.success(Unit) - } - val sut = FlushQueue( - flushManager, - repository, - parselyAPIConnection, - this - ) - - // when - sut.invoke(false) - runCurrent() - - // then - assertThat(flushManager.stopped).isTrue - } - @Test fun `given non-empty local storage, when flushing queue with not skipping sending events fails, then flush manager is not stopped`() = runTest {