Skip to content

Commit 5d50249

Browse files
fix: Flaky 'allTasks' integration test due to race condition
The integration test 'allTasks and allTaskIds with allGroups set to true' in `general_test.dart` was flaky because the default download task (using `https://google.com`) completed too quickly, often finishing before the `allTasks()` assertion could execute. This resulted in an empty list of tasks and a test failure. This change updates the test to use `urlWithContentLength` (a ~5MB file) to ensure the download takes sufficient time, keeping the tasks in an active state (enqueued/running) during the assertions. Addresses the race condition where `allTasks` returned 0 active tasks instead of the expected 2.
1 parent 5568eb4 commit 5d50249

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

example/integration_test/general_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ void main() {
549549
(widgetTester) async {
550550
print('Starting allTasks with allGroups set to true');
551551
FileDownloader().registerCallbacks(taskStatusCallback: statusCallback);
552+
task = DownloadTask(url: urlWithContentLength, filename: defaultFilename);
552553
final task2 = task.copyWith(group: 'group2');
553554
expect(await FileDownloader().enqueue(task), isTrue);
554555
expect(await FileDownloader().enqueue(task2), isTrue);

0 commit comments

Comments
 (0)