| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 content-disposition: form-data; name="file" | 209 content-disposition: form-data; name="file" |
| 210 | 210 |
| 211 hello | 211 hello |
| 212 --{{boundary}}-- | 212 --{{boundary}}-- |
| 213 ''')); | 213 ''')); |
| 214 }); | 214 }); |
| 215 | 215 |
| 216 group('in a temp directory', () { | 216 group('in a temp directory', () { |
| 217 var tempDir; | 217 var tempDir; |
| 218 setUp(() { | 218 setUp(() { |
| 219 tempDir = new Directory('').createTempSync(); | 219 tempDir = Directory.systemTemp.createTempSync('http_test_'); |
| 220 }); | 220 }); |
| 221 | 221 |
| 222 tearDown(() => tempDir.deleteSync(recursive: true)); | 222 tearDown(() => tempDir.deleteSync(recursive: true)); |
| 223 | 223 |
| 224 test('with a file from disk', () { | 224 test('with a file from disk', () { |
| 225 expect(new Future.sync(() { | 225 expect(new Future.sync(() { |
| 226 var filePath = path.join(tempDir.path, 'test-file'); | 226 var filePath = path.join(tempDir.path, 'test-file'); |
| 227 new File(filePath).writeAsStringSync('hello'); | 227 new File(filePath).writeAsStringSync('hello'); |
| 228 return http.MultipartFile.fromPath('file', filePath); | 228 return http.MultipartFile.fromPath('file', filePath); |
| 229 }).then((file) { | 229 }).then((file) { |
| 230 var request = new http.MultipartRequest('POST', dummyUrl); | 230 var request = new http.MultipartRequest('POST', dummyUrl); |
| 231 request.files.add(file); | 231 request.files.add(file); |
| 232 | 232 |
| 233 expect(request, bodyMatches(''' | 233 expect(request, bodyMatches(''' |
| 234 --{{boundary}} | 234 --{{boundary}} |
| 235 content-type: application/octet-stream | 235 content-type: application/octet-stream |
| 236 content-disposition: form-data; name="file"; filename="test-file" | 236 content-disposition: form-data; name="file"; filename="test-file" |
| 237 | 237 |
| 238 hello | 238 hello |
| 239 --{{boundary}}-- | 239 --{{boundary}}-- |
| 240 ''')); | 240 ''')); |
| 241 }), completes); | 241 }), completes); |
| 242 }); | 242 }); |
| 243 }); | 243 }); |
| 244 } | 244 } |
| OLD | NEW |