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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/pkg.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library multipart_test; 5 library multipart_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:utf'; 9 import 'dart:utf';
10 10
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 expect(request, bodyMatches(''' 197 expect(request, bodyMatches('''
198 --{{boundary}} 198 --{{boundary}}
199 content-type: application/octet-stream 199 content-type: application/octet-stream
200 content-disposition: form-data; name="file" 200 content-disposition: form-data; name="file"
201 201
202 hello 202 hello
203 --{{boundary}}-- 203 --{{boundary}}--
204 ''')); 204 '''));
205 }); 205 });
206 206
207 test('with a file from disk', () { 207 group('in a temp directory', () {
208 var tempDir = new Directory('').createTempSync(); 208 var tempDir;
209 setUp(() {
210 tempDir = new Directory('').createTempSync();
211 });
209 212
210 expect(new Future.of(() { 213 tearDown(() => tempDir.deleteSync(recursive: true));
211 var filePath = path.join(tempDir.path, 'test-file');
212 new File(filePath).writeAsStringSync('hello');
213 return http.MultipartFile.fromPath('file', filePath);
214 }).then((file) {
215 var request = new http.MultipartRequest('POST', dummyUrl);
216 request.files.add(file);
217 214
218 expect(request, bodyMatches(''' 215 test('with a file from disk', () {
216 expect(new Future.of(() {
217 var filePath = path.join(tempDir.path, 'test-file');
218 new File(filePath).writeAsStringSync('hello');
219 return http.MultipartFile.fromPath('file', filePath);
220 }).then((file) {
221 var request = new http.MultipartRequest('POST', dummyUrl);
222 request.files.add(file);
223
224 expect(request, bodyMatches('''
219 --{{boundary}} 225 --{{boundary}}
220 content-type: application/octet-stream 226 content-type: application/octet-stream
221 content-disposition: form-data; name="file"; filename="test-file" 227 content-disposition: form-data; name="file"; filename="test-file"
222 228
223 hello 229 hello
224 --{{boundary}}-- 230 --{{boundary}}--
225 ''')); 231 '''));
226 }).whenComplete(() => tempDir.delete(recursive: true)), completes); 232 }), completes);
233 });
227 }); 234 });
228 } 235 }
OLDNEW
« 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