mirror of
https://github.com/rclone/rclone.git
synced 2026-03-26 03:12:36 -04:00
vfs/vfscache/downloaders: fix flaky TestDownloaders/EnsureDownloader
The test was racy: it asserted the async download hadn't completed yet (which could fail on fast machines) then slept for a fixed 1 second (which could be too short on slow CI runners, especially macOS). Replace with assert.Eventually which polls until the download completes, with a generous timeout.
This commit is contained in:
@@ -122,9 +122,9 @@ func TestDownloaders(t *testing.T) {
|
||||
r := ranges.Range{Pos: 40 * 1024 * 1024, Size: 250}
|
||||
err := dls.EnsureDownloader(r)
|
||||
require.NoError(t, err)
|
||||
// FIXME racy test
|
||||
assert.False(t, item.HasRange(r))
|
||||
time.Sleep(time.Second)
|
||||
assert.True(t, item.HasRange(r))
|
||||
// The download happens asynchronously, so poll until it completes
|
||||
assert.Eventually(t, func() bool {
|
||||
return item.HasRange(r)
|
||||
}, 10*time.Second, 100*time.Millisecond, "timed out waiting for download to complete")
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user