Skip to content

Commit d609401

Browse files
Fix flaky reset test in general_test.dart
The `reset` test in `example/integration_test/general_test.dart` was flaky because it used a very small file (google.com) for the download task. This often caused the task to complete before `reset()` could cancel it, resulting in `reset()` returning 0 (expected 1) and the final task status being `complete` (expected `canceled`). This change updates the test to use `urlWithContentLength` (a ~5MB file), ensuring the download takes long enough to be successfully cancelled by `reset()`.
1 parent db16711 commit d609401

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

example/integration_test/general_test.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,10 @@ void main() {
506506
print('Starting reset');
507507
await Future.delayed(const Duration(seconds: 2)); // clear cancellations
508508
FileDownloader().registerCallbacks(taskStatusCallback: statusCallback);
509-
expect(await FileDownloader().enqueue(task), isTrue);
509+
// use a larger file to ensure the task does not complete before reset is called
510+
var resetTask =
511+
DownloadTask(url: urlWithContentLength, filename: defaultFilename);
512+
expect(await FileDownloader().enqueue(resetTask), isTrue);
510513
expect(await FileDownloader().reset(group: 'non-default'), equals(0));
511514
expect(await FileDownloader().reset(), equals(1));
512515
await Future.delayed(const Duration(seconds: 1));

0 commit comments

Comments
 (0)