| OLD | NEW | 
|---|
| 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 pub_uploader_test; | 5 library pub_uploader_test; | 
| 6 | 6 | 
| 7 import 'dart:io'; | 7 import 'dart:io'; | 
| 8 import 'dart:json' as json; | 8 import 'dart:json' as json; | 
| 9 | 9 | 
| 10 import 'test_pub.dart'; | 10 import 'test_pub.dart'; | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 42         args: ['uploader', 'foo', 'email'], | 42         args: ['uploader', 'foo', 'email'], | 
| 43         output: USAGE_STRING, exitCode: 64)); | 43         output: USAGE_STRING, exitCode: 64)); | 
| 44   }); | 44   }); | 
| 45 | 45 | 
| 46   test('adds an uploader', () { | 46   test('adds an uploader', () { | 
| 47     var server = new ScheduledServer(); | 47     var server = new ScheduledServer(); | 
| 48     credentialsFile(server, 'access token').scheduleCreate(); | 48     credentialsFile(server, 'access token').scheduleCreate(); | 
| 49     var pub = startPubUploader(server, ['--package', 'pkg', 'add', 'email']); | 49     var pub = startPubUploader(server, ['--package', 'pkg', 'add', 'email']); | 
| 50 | 50 | 
| 51     server.handle('POST', '/packages/pkg/uploaders.json', (request, response) { | 51     server.handle('POST', '/packages/pkg/uploaders.json', (request, response) { | 
| 52       expect(consumeInputStream(request.inputStream).then((bodyBytes) { | 52       expect(wrapInputStream(request.inputStream).toBytes().then((bodyBytes) { | 
| 53         expect(new String.fromCharCodes(bodyBytes), equals('email=email')); | 53         expect(new String.fromCharCodes(bodyBytes), equals('email=email')); | 
| 54 | 54 | 
| 55         response.headers.contentType = new ContentType("application", "json"); | 55         response.headers.contentType = new ContentType("application", "json"); | 
| 56         response.outputStream.writeString(json.stringify({ | 56         response.outputStream.writeString(json.stringify({ | 
| 57           'success': {'message': 'Good job!'} | 57           'success': {'message': 'Good job!'} | 
| 58         })); | 58         })); | 
| 59         response.outputStream.close(); | 59         response.outputStream.close(); | 
| 60       }), completes); | 60       }), completes); | 
| 61     }); | 61     }); | 
| 62 | 62 | 
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 178       response.outputStream.close(); | 178       response.outputStream.close(); | 
| 179     }); | 179     }); | 
| 180 | 180 | 
| 181     expectLater(pub.nextErrLine(), equals('Invalid server response:')); | 181     expectLater(pub.nextErrLine(), equals('Invalid server response:')); | 
| 182     expectLater(pub.nextErrLine(), equals('{not json')); | 182     expectLater(pub.nextErrLine(), equals('{not json')); | 
| 183     pub.shouldExit(1); | 183     pub.shouldExit(1); | 
| 184 | 184 | 
| 185     run(); | 185     run(); | 
| 186   }); | 186   }); | 
| 187 } | 187 } | 
| OLD | NEW | 
|---|