| 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_lish_test; | 5 library pub_lish_test; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 import 'dart:json'; | 8 import 'dart:json'; |
| 9 | 9 |
| 10 import 'test_pub.dart'; | 10 import 'test_pub.dart'; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 expectLater(pub.nextErrLine(), equals('OAuth2 authorization failed (your ' | 90 expectLater(pub.nextErrLine(), equals('OAuth2 authorization failed (your ' |
| 91 'token sucks).')); | 91 'token sucks).')); |
| 92 expectLater(pub.nextLine(), equals('Pub needs your authorization to upload ' | 92 expectLater(pub.nextLine(), equals('Pub needs your authorization to upload ' |
| 93 'packages on your behalf.')); | 93 'packages on your behalf.')); |
| 94 pub.kill(); | 94 pub.kill(); |
| 95 | 95 |
| 96 run(); | 96 run(); |
| 97 }); | 97 }); |
| 98 | 98 |
| 99 test('package validation has an error', () { |
| 100 var package = package("test_pkg", "1.0.0"); |
| 101 package.remove("homepage"); |
| 102 dir(appPath, [pubspec(package)]).scheduleCreate(); |
| 103 |
| 104 var server = new ScheduledServer(); |
| 105 credentialsFile(server, 'access token').scheduleCreate(); |
| 106 var pub = startPubLish(server); |
| 107 server.ignore('GET', '/packages/versions/new.json'); |
| 108 |
| 109 pub.shouldExit(1); |
| 110 expectLater(pub.remainingStderr(), contains("Package validation failed.")); |
| 111 |
| 112 run(); |
| 113 }); |
| 114 |
| 115 test('package validation has a warning and is canceled', () { |
| 116 var package = package("test_pkg", "1.0.0"); |
| 117 package["author"] = "Nathan Weizenbaum"; |
| 118 dir(appPath, [pubspec(package)]).scheduleCreate(); |
| 119 |
| 120 var server = new ScheduledServer(); |
| 121 credentialsFile(server, 'access token').scheduleCreate(); |
| 122 var pub = startPubLish(server); |
| 123 server.ignore('GET', '/packages/versions/new.json'); |
| 124 |
| 125 pub.writeLine("n"); |
| 126 pub.shouldExit(1); |
| 127 expectLater(pub.remainingStderr(), contains("Package upload canceled.")); |
| 128 |
| 129 run(); |
| 130 }); |
| 131 |
| 132 test('package validation has a warning and continues', () { |
| 133 var package = package("test_pkg", "1.0.0"); |
| 134 package["author"] = "Nathan Weizenbaum"; |
| 135 dir(appPath, [pubspec(package)]).scheduleCreate(); |
| 136 |
| 137 var server = new ScheduledServer(); |
| 138 credentialsFile(server, 'access token').scheduleCreate(); |
| 139 var pub = startPubLish(server); |
| 140 pub.writeLine("y"); |
| 141 handleUploadForm(server); |
| 142 handleUpload(server); |
| 143 |
| 144 server.handle('GET', '/create', (request, response) { |
| 145 response.outputStream.writeString(JSON.stringify({ |
| 146 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'} |
| 147 })); |
| 148 return closeHttpResponse(request, response); |
| 149 }); |
| 150 |
| 151 pub.shouldExit(0); |
| 152 expectLater(pub.remainingStdout(), |
| 153 contains('Package test_pkg 1.0.0 uploaded!')); |
| 154 |
| 155 run(); |
| 156 }); |
| 157 |
| 99 test('upload form provides an error', () { | 158 test('upload form provides an error', () { |
| 100 var server = new ScheduledServer(); | 159 var server = new ScheduledServer(); |
| 101 credentialsFile(server, 'access token').scheduleCreate(); | 160 credentialsFile(server, 'access token').scheduleCreate(); |
| 102 var pub = startPubLish(server); | 161 var pub = startPubLish(server); |
| 103 | 162 |
| 104 server.handle('GET', '/packages/versions/new.json', (request, response) { | 163 server.handle('GET', '/packages/versions/new.json', (request, response) { |
| 105 response.statusCode = 400; | 164 response.statusCode = 400; |
| 106 response.outputStream.writeString(JSON.stringify({ | 165 response.outputStream.writeString(JSON.stringify({ |
| 107 'error': {'message': 'your request sucked'} | 166 'error': {'message': 'your request sucked'} |
| 108 })); | 167 })); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 return closeHttpResponse(request, response); | 397 return closeHttpResponse(request, response); |
| 339 }); | 398 }); |
| 340 | 399 |
| 341 expectLater(pub.nextErrLine(), equals('Invalid server response:')); | 400 expectLater(pub.nextErrLine(), equals('Invalid server response:')); |
| 342 expectLater(pub.nextErrLine(), equals(JSON.stringify(body))); | 401 expectLater(pub.nextErrLine(), equals(JSON.stringify(body))); |
| 343 pub.shouldExit(1); | 402 pub.shouldExit(1); |
| 344 | 403 |
| 345 run(); | 404 run(); |
| 346 }); | 405 }); |
| 347 } | 406 } |
| OLD | NEW |