Skip to content
Open
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
7 changes: 6 additions & 1 deletion rest/replicatortest/replicator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2129,7 +2129,12 @@ func TestActiveReplicatorPullBasic(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, "rt2", body["source"])

assert.Equal(t, strconv.FormatUint(remoteDoc.Sequence, 10), ar.GetStatus(ctx1).LastSeqPull)
// replication status updates just after the document has been written in a blip handler callback, so the
// document can exist before stat is updated
require.EventuallyWithT(t, func(c *assert.CollectT) {
status := ar.GetStatus(ctx1)
assert.Equal(c, strconv.FormatUint(remoteDoc.Sequence, 10), status.LastSeqPull, "status=%#+v", status)
}, 5*time.Second, 10*time.Millisecond)
Comment on lines +2134 to +2137
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timeout (5 seconds) and poll interval (10 milliseconds) should be defined as named constants rather than magic numbers. This improves maintainability and makes it easier to adjust timing parameters consistently across tests.

Suggested change
require.EventuallyWithT(t, func(c *assert.CollectT) {
status := ar.GetStatus(ctx1)
assert.Equal(c, strconv.FormatUint(remoteDoc.Sequence, 10), status.LastSeqPull, "status=%#+v", status)
}, 5*time.Second, 10*time.Millisecond)
const (
// These constants control how long we wait, and how often we poll, for the replicator status to reflect
// the sequence of the last pulled document.
replicatorStatusTimeout = 5 * time.Second
replicatorStatusPollInterval = 10 * time.Millisecond
)
require.EventuallyWithT(t, func(c *assert.CollectT) {
status := ar.GetStatus(ctx1)
assert.Equal(c, strconv.FormatUint(remoteDoc.Sequence, 10), status.LastSeqPull, "status=%#+v", status)
}, replicatorStatusTimeout, replicatorStatusPollInterval)

Copilot uses AI. Check for mistakes.
})
}

Expand Down
Loading