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

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

Issue 12374027: Fix the pkg/http multipart test to avoid a race condition. (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 | « no previous file | pkg/pkg.status » ('j') | 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 71975311ecc77737ef9615a8b4615149b4e03250..c3c3dd9ddc9f68bd1a7add8157b96bee80c0a9d2 100644
--- a/pkg/http/test/multipart_test.dart
+++ b/pkg/http/test/multipart_test.dart
@@ -204,18 +204,24 @@ void main() {
'''));
});
- 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('''
+ group('in a temp directory', () {
+ var tempDir;
+ setUp(() {
+ tempDir = new Directory('').createTempSync();
+ });
+
+ tearDown(() => tempDir.deleteSync(recursive: true));
+
+ test('with a file from disk', () {
+ 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"
@@ -223,6 +229,7 @@ void main() {
hello
--{{boundary}}--
'''));
- }).whenComplete(() => tempDir.delete(recursive: true)), completes);
+ }), completes);
+ });
});
}
« no previous file with comments | « no previous file | pkg/pkg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698