forked from customerio/customerio-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: delete expired background queue tasks
- Loading branch information
1 parent
79ebdec
commit 8dca8b7
Showing
22 changed files
with
363 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 4 additions & 6 deletions
10
common-test/src/main/java/io/customer/common_test/DateUtilStub.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
package io.customer.common_test | ||
|
||
import io.customer.base.extenstions.unixTimeToDate | ||
import io.customer.base.extenstions.getUnixTimestamp | ||
import io.customer.sdk.util.DateUtil | ||
import java.util.* | ||
|
||
/** | ||
* Convenient alternative to mocking [DateUtil] in your test since the code is boilerplate. | ||
*/ | ||
class DateUtilStub : DateUtil { | ||
// modify this value in your test class if you need to. | ||
var givenDateMillis = 1646238885L | ||
|
||
val givenDate: Date | ||
get() = givenDateMillis.unixTimeToDate() | ||
// modify this value in your test class if you need to. | ||
var givenDate: Date = Date(1646238885L) | ||
|
||
override val now: Date | ||
get() = givenDate | ||
|
||
override val nowUnixTimestamp: Long | ||
get() = givenDateMillis | ||
get() = now.getUnixTimestamp() | ||
} |
29 changes: 29 additions & 0 deletions
29
common-test/src/main/java/io/customer/common_test/util/DispatchersProviderStub.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.customer.common_test.util | ||
|
||
import io.customer.sdk.util.DispatchersProvider | ||
import io.customer.sdk.util.SdkDispatchers | ||
import kotlinx.coroutines.CoroutineDispatcher | ||
import kotlinx.coroutines.ExperimentalCoroutinesApi | ||
import kotlinx.coroutines.test.TestCoroutineDispatcher | ||
|
||
class DispatchersProviderStub : DispatchersProvider { | ||
private var overrideBackground: CoroutineDispatcher? = null | ||
private var overrideMain: CoroutineDispatcher? = null | ||
|
||
// If your test function requires real dispatchers to be used, call this function. | ||
// the default behavior is test dispatchers because they are fast and synchronous for more predictable test execution. | ||
fun setRealDispatchers() { | ||
SdkDispatchers().also { | ||
overrideBackground = it.background | ||
overrideMain = it.main | ||
} | ||
} | ||
|
||
@OptIn(ExperimentalCoroutinesApi::class) | ||
override val background: CoroutineDispatcher | ||
get() = overrideBackground ?: TestCoroutineDispatcher() | ||
|
||
@OptIn(ExperimentalCoroutinesApi::class) | ||
override val main: CoroutineDispatcher | ||
get() = overrideMain ?: TestCoroutineDispatcher() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.