Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions android/app/src/main/java/com/noop/push/PushCoordinator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class PushCoordinator(
private val transport: PushTransport,
private val progress: PushProgressStore,
private val sourceId: String,
private val today: () -> LocalDate = { LocalDate.now() },
private val zoneId: ZoneId = ZoneId.systemDefault(),
private val today: () -> LocalDate,
private val zoneId: ZoneId,
private val destinationStillCurrent: () -> Boolean = { true },
) {
suspend fun pushAppend(table: PushAppendTable, deviceId: String): PushResult {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import androidx.work.ListenableWorker
import androidx.work.WorkerParameters
import com.noop.R
import com.noop.data.WhoopDatabase
import java.time.LocalDate
import java.time.ZoneId
import kotlinx.coroutines.CancellationException

internal fun persistedDeviceIndex(startDeviceIndex: Int, nextDeviceIndex: Int, retryableFailure: Boolean): Int =
Expand Down Expand Up @@ -223,6 +225,10 @@ class SelfHostedPushWorker(
transport = transport,
progress = progress,
sourceId = sourceId,
// The real clock and zone live HERE, at the one caller that wants them, rather than as
// defaults 35 test constructions could inherit without saying so (#1787).
today = { LocalDate.now() },
zoneId = ZoneId.systemDefault(),
destinationStillCurrent = { settings.enabledEndpoint() == endpoint },
).pushKnownDevices(startDeviceIndex, MAX_DEVICES_PER_RUN, capabilities)
settings.recordAcceptedBatches(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PushCoordinatorTest {

try {
PushCoordinator(
source, transport, MemoryProgress(), SOURCE_A,
source, transport, MemoryProgress(), SOURCE_A, pinnedToday, ZoneId.of("UTC"),
destinationStillCurrent = { settings.enabledEndpoint() == first },
).pushKnownDevices(
capabilities = PushCapabilities(
Expand Down Expand Up @@ -186,6 +186,8 @@ class PushCoordinatorTest {
throwing,
progress,
SOURCE_A,
pinnedToday,
ZoneId.of("UTC"),
).pushAppend(PushAppendTable.HR_SAMPLE, "a")
assertTrue(result is PushResult.Rejected && result.retryable)
assertTrue(progress.cursors.isEmpty())
Expand Down
Loading