Skip to content

Adds test to verify issue #205 #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pubspec.lock
flutter_export_environment.sh

examples/all_plugins/pubspec.yaml
Flutter.podspec

Podfile
Podfile.lock
Expand Down
75 changes: 44 additions & 31 deletions example/integration_test/flutter_uploader_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:math';
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:integration_test/integration_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:path_provider/path_provider.dart';
Expand Down Expand Up @@ -48,23 +49,30 @@ void main() {
group('multipart/form-data uploads', () {
final url = baseUrl;

testWidgets('single file', (WidgetTester tester) async {
var fileItem = FileItem(path: await _tmpFile(), field: 'file');
for (final method in UploadMethod.values) {
testWidgets('single file via ${describeEnum(method)}', (_) async {
var fileItem = FileItem(path: await _tmpFile(), field: 'file');

final taskId = await uploader.enqueue(
MultipartFormDataUpload(url: url.toString(), files: [fileItem]),
);
final taskId = await uploader.enqueue(
MultipartFormDataUpload(
url: url.toString(),
files: [fileItem],
method: method,
),
);

expect(taskId, isNotNull);
expect(taskId, isNotNull);

final res = await uploader.result.firstWhere(isCompleted(taskId));
final json = jsonDecode(res.response!);
final res = await uploader.result.firstWhere(isCompleted(taskId));
final json = jsonDecode(res.response!);

expect(json['message'], 'Successfully uploaded');
expect(res.statusCode, 200);
expect(json['request']['headers']['accept'], '*/*');
expect(res.status, UploadTaskStatus.complete);
});
expect(json['message'], 'Successfully uploaded');
expect(res.statusCode, 200);
expect(json['request']['method'], describeEnum(method));
expect(json['request']['headers']['accept'], '*/*');
expect(res.status, UploadTaskStatus.complete);
});
}

testWidgets('multiple uploads stresstest', (WidgetTester tester) async {
final taskIds = <String>[];
Expand Down Expand Up @@ -193,24 +201,29 @@ void main() {
group('binary uploads', () {
final url = baseUrl.replace(path: baseUrl.path + 'Binary');

testWidgets('single file', (WidgetTester tester) async {
final taskId = await uploader.enqueue(
RawUpload(
url: url.toString(),
path: await _tmpFile(),
),
);

expect(taskId, isNotNull);

final res = await uploader.result.firstWhere(isCompleted(taskId));
final json = jsonDecode(res.response!);

expect(json['message'], 'Successfully uploaded');
expect(res.statusCode, 200);
expect(json['headers']['accept'], '*/*');
expect(res.status, UploadTaskStatus.complete);
});
for (final method in UploadMethod.values) {
testWidgets('single file via ${describeEnum(method)}',
(WidgetTester tester) async {
final taskId = await uploader.enqueue(
RawUpload(
url: url.toString(),
path: await _tmpFile(),
method: method,
),
);

expect(taskId, isNotNull);

final res = await uploader.result.firstWhere(isCompleted(taskId));
final json = jsonDecode(res.response!);

expect(json['message'], 'Successfully uploaded');
expect(res.statusCode, 200);
expect(json['method'], describeEnum(method));
expect(json['headers']['accept'], '*/*');
expect(res.status, UploadTaskStatus.complete);
});
}

testWidgets('multiple uploads stresstest', (WidgetTester tester) async {
final taskIds = <String>[];
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>9.0</string>
</dict>
</plist>