Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Unified Diff: pkg/http/test/multipart_test.dart

Issue 12351006: Change MultipartFile.fromFile to MultipartFile.fromPath in pkg/http. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/http/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/test/multipart_test.dart
diff --git a/pkg/http/test/multipart_test.dart b/pkg/http/test/multipart_test.dart
index 9c83ce1d43d13c0a75e576afc539a183b086fb9a..9ebcb834bce2927da70ee56f1f471cdd37a0984b 100644
--- a/pkg/http/test/multipart_test.dart
+++ b/pkg/http/test/multipart_test.dart
@@ -8,6 +8,7 @@ import 'dart:async';
import 'dart:io';
import 'dart:utf';
+import 'package:pathos/path.dart' as path;
import 'package:unittest/unittest.dart';
import 'package:http/http.dart' as http;
import 'package:http/src/utils.dart';
@@ -202,4 +203,26 @@ void main() {
--{{boundary}}--
'''));
});
+
+ test('with a file from disk', () {
+ var tempDir = new Directory('').createTempSync();
+
+ expect(new Future.of(() {
+ var filePath = path.join(tempDir.path, 'test-file');
+ new File(filePath).writeAsStringSync('hello');
+ return http.MultipartFile.fromPath('file', filePath);
+ }).then((file) {
+ var request = new http.MultipartRequest('POST', dummyUrl);
+ request.files.add(file);
+
+ expect(request, bodyMatches('''
+ --{{boundary}}
+ content-type: application/octet-stream
+ content-disposition: form-data; name="file"; filename="test-file"
+
+ hello
+ --{{boundary}}--
+ '''));
+ }).whenComplete(() => tempDir.delete(recursive: true)), completes);
+ });
}
« no previous file with comments | « pkg/http/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698