Skip to content

Commit

Permalink
feat: do not stop FlushManager on successful flush
Browse files Browse the repository at this point in the history
If stored queue will be empty, on next execution of `FlushQueue`, the manager will be stopped anyway.

#92 (comment)
  • Loading branch information
wzieba committed Nov 24, 2023
1 parent 2c0ce6e commit 784a021
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
26 changes: 0 additions & 26 deletions parsely/src/test/java/com/parsely/parselyandroid/FlushQueueTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 784a021

Please sign in to comment.