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

Unified Diff: utils/tests/pub/pub_lish_test.dart

Issue 12782005: Revert "Use scheduled_test for Pub tests." (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/tests/pub/pub_cache_test.dart ('k') | utils/tests/pub/pub_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tests/pub/pub_lish_test.dart
diff --git a/utils/tests/pub/pub_lish_test.dart b/utils/tests/pub/pub_lish_test.dart
index 8b38f2e8ae5b2c26914b18c748c2a8709ea3aba3..495055463286a5c75b7b809b888516c0bbfe17ec 100644
--- a/utils/tests/pub/pub_lish_test.dart
+++ b/utils/tests/pub/pub_lish_test.dart
@@ -7,16 +7,13 @@ library pub_lish_test;
import 'dart:io';
import 'dart:json' as json;
-import '../../../pkg/scheduled_test/lib/scheduled_test.dart';
-import '../../../pkg/scheduled_test/lib/scheduled_server.dart';
-
+import 'test_pub.dart';
+import '../../../pkg/unittest/lib/unittest.dart';
import '../../pub/exit_codes.dart' as exit_codes;
import '../../pub/io.dart';
-import 'descriptor.dart' as d;
-import 'test_pub.dart';
void handleUploadForm(ScheduledServer server, [Map body]) {
- server.handle('GET', '/packages/versions/new.json', (request) {
+ server.handle('GET', '/packages/versions/new.json', (request, response) {
return server.url.then((url) {
expect(request.headers.value('authorization'),
equals('Bearer access token'));
@@ -31,55 +28,53 @@ void handleUploadForm(ScheduledServer server, [Map body]) {
};
}
- request.response.headers.contentType =
- new ContentType("application", "json");
- request.response.write(json.stringify(body));
- request.response.close();
+ response.headers.contentType = new ContentType("application", "json");
+ response.write(json.stringify(body));
+ response.close();
});
});
}
void handleUpload(ScheduledServer server) {
- server.handle('POST', '/upload', (request) {
+ server.handle('POST', '/upload', (request, response) {
// TODO(nweiz): Once a multipart/form-data parser in Dart exists, validate
// that the request body is correctly formatted. See issue 6952.
return drainStream(request).then((_) {
return server.url;
}).then((url) {
- request.response.statusCode = 302;
- request.response.headers.set(
- 'location', url.resolve('/create').toString());
- request.response.close();
+ response.statusCode = 302;
+ response.headers.set('location', url.resolve('/create').toString());
+ response.close();
});
});
}
main() {
initConfig();
- setUp(() => d.validPackage.create());
+ setUp(() => normalPackage.scheduleCreate());
integration('archives and uploads a package', () {
var server = new ScheduledServer();
- d.credentialsFile(server, 'access token').create();
- var pub = startPublish(server);
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server);
confirmPublish(pub);
handleUploadForm(server);
handleUpload(server);
- server.handle('GET', '/create', (request) {
- request.response.write(json.stringify({
+ server.handle('GET', '/create', (request, response) {
+ response.write(json.stringify({
'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
}));
- request.response.close();
+ response.close();
});
// TODO(rnystrom): The confirm line is run together with this one because
// in normal usage, the user will have entered a newline on stdin which
// gets echoed to the terminal. Do something better here?
- expect(pub.nextLine(), completion(equals(
+ expectLater(pub.nextLine(), equals(
'Looks great! Are you ready to upload your package (y/n)?'
- ' Package test_pkg 1.0.0 uploaded!')));
+ ' Package test_pkg 1.0.0 uploaded!'));
pub.shouldExit(0);
});
@@ -87,126 +82,125 @@ main() {
// test that "pub lish" chooses the correct files to publish.
integration('package validation has an error', () {
- var pkg = packageMap("test_pkg", "1.0.0");
+ var pkg = package("test_pkg", "1.0.0");
pkg.remove("homepage");
- d.dir(appPath, [d.pubspec(pkg)]).create();
+ dir(appPath, [pubspec(pkg)]).scheduleCreate();
var server = new ScheduledServer();
- var pub = startPublish(server);
+ var pub = startPubLish(server);
pub.shouldExit(0);
- expect(pub.remainingStderr(), completion(contains(
- "Sorry, your package is missing a requirement and can't be published "
- "yet.")));
+ expectLater(pub.remainingStderr(),
+ contains("Sorry, your package is missing a requirement and can't be "
+ "published yet."));
});
integration('preview package validation has a warning', () {
- var pkg = packageMap("test_pkg", "1.0.0");
+ var pkg = package("test_pkg", "1.0.0");
pkg["author"] = "Nathan Weizenbaum";
- d.dir(appPath, [d.pubspec(pkg)]).create();
+ dir(appPath, [pubspec(pkg)]).scheduleCreate();
var server = new ScheduledServer();
- var pub = startPublish(server, args: ['--dry-run']);
+ var pub = startPubLish(server, args: ['--dry-run']);
pub.shouldExit(0);
- expect(pub.remainingStderr(), completion(contains(
- 'Suggestions:\n* Author "Nathan Weizenbaum" in pubspec.yaml should '
- 'have an email address\n'
- ' (e.g. "name <email>").\n\n'
- 'Package has 1 warning.')));
+ expectLater(pub.remainingStderr(),
+ contains('Suggestions:\n* Author "Nathan Weizenbaum" in pubspec.yaml'
+ ' should have an email address\n'
+ ' (e.g. "name <email>").\n\n'
+ 'Package has 1 warning.'));
});
integration('preview package validation has no warnings', () {
- var pkg = packageMap("test_pkg", "1.0.0");
+ var pkg = package("test_pkg", "1.0.0");
pkg["author"] = "Nathan Weizenbaum <nweiz@google.com>";
- d.dir(appPath, [d.pubspec(pkg)]).create();
+ dir(appPath, [pubspec(pkg)]).scheduleCreate();
var server = new ScheduledServer();
- var pub = startPublish(server, args: ['--dry-run']);
+ var pub = startPubLish(server, args: ['--dry-run']);
pub.shouldExit(0);
- expect(pub.remainingStderr(),
- completion(contains('Package has 0 warnings.')));
+ expectLater(pub.remainingStderr(),
+ contains('Package has 0 warnings.'));
});
integration('package validation has a warning and is canceled', () {
- var pkg = packageMap("test_pkg", "1.0.0");
+ var pkg = package("test_pkg", "1.0.0");
pkg["author"] = "Nathan Weizenbaum";
- d.dir(appPath, [d.pubspec(pkg)]).create();
+ dir(appPath, [pubspec(pkg)]).scheduleCreate();
var server = new ScheduledServer();
- var pub = startPublish(server);
+ var pub = startPubLish(server);
pub.writeLine("n");
pub.shouldExit(0);
- expect(pub.remainingStderr(),
- completion(contains("Package upload canceled.")));
+ expectLater(pub.remainingStderr(), contains("Package upload canceled."));
});
integration('package validation has a warning and continues', () {
- var pkg = packageMap("test_pkg", "1.0.0");
+ var pkg = package("test_pkg", "1.0.0");
pkg["author"] = "Nathan Weizenbaum";
- d.dir(appPath, [d.pubspec(pkg)]).create();
+ dir(appPath, [pubspec(pkg)]).scheduleCreate();
var server = new ScheduledServer();
- d.credentialsFile(server, 'access token').create();
- var pub = startPublish(server);
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server);
pub.writeLine("y");
handleUploadForm(server);
handleUpload(server);
- server.handle('GET', '/create', (request) {
- request.response.write(json.stringify({
+ server.handle('GET', '/create', (request, response) {
+ response.write(json.stringify({
'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
}));
- request.response.close();
+ response.close();
});
pub.shouldExit(0);
- expect(pub.remainingStdout(),
- completion(contains('Package test_pkg 1.0.0 uploaded!')));
+ expectLater(pub.remainingStdout(),
+ contains('Package test_pkg 1.0.0 uploaded!'));
});
integration('upload form provides an error', () {
var server = new ScheduledServer();
- d.credentialsFile(server, 'access token').create();
- var pub = startPublish(server);
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server);
confirmPublish(pub);
- server.handle('GET', '/packages/versions/new.json', (request) {
- request.response.statusCode = 400;
- request.response.write(json.stringify({
+ server.handle('GET', '/packages/versions/new.json', (request, response) {
+ response.statusCode = 400;
+ response.write(json.stringify({
'error': {'message': 'your request sucked'}
}));
- request.response.close();
+ response.close();
});
- expect(pub.nextErrLine(), completion(equals('your request sucked')));
+ expectLater(pub.nextErrLine(), equals('your request sucked'));
pub.shouldExit(1);
});
integration('upload form provides invalid JSON', () {
var server = new ScheduledServer();
- d.credentialsFile(server, 'access token').create();
- var pub = startPublish(server);
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server);
confirmPublish(pub);
- server.handle('GET', '/packages/versions/new.json', (request) {
- request.response.write('{not json');
- request.response.close();
+ server.handle('GET', '/packages/versions/new.json', (request, response) {
+ response.write('{not json');
+ response.close();
});
- expect(pub.nextErrLine(), completion(equals('Invalid server response:')));
- expect(pub.nextErrLine(), completion(equals('{not json')));
+ expectLater(pub.nextErrLine(), equals('Invalid server response:'));
+ expectLater(pub.nextErrLine(), equals('{not json'));
pub.shouldExit(1);
});
integration('upload form is missing url', () {
var server = new ScheduledServer();
- d.credentialsFile(server, 'access token').create();
- var pub = startPublish(server);
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server);
confirmPublish(pub);
@@ -218,15 +212,15 @@ main() {
};
handleUploadForm(server, body);
- expect(pub.nextErrLine(), completion(equals('Invalid server response:')));
- expect(pub.nextErrLine(), completion(equals(json.stringify(body))));
+ expectLater(pub.nextErrLine(), equals('Invalid server response:'));
+ expectLater(pub.nextErrLine(), equals(json.stringify(body)));
pub.shouldExit(1);
});
integration('upload form url is not a string', () {
var server = new ScheduledServer();
- d.credentialsFile(server, 'access token').create();
- var pub = startPublish(server);
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server);
confirmPublish(pub);
@@ -239,43 +233,43 @@ main() {
};
handleUploadForm(server, body);
- expect(pub.nextErrLine(), completion(equals('Invalid server response:')));
- expect(pub.nextErrLine(), completion(equals(json.stringify(body))));
+ expectLater(pub.nextErrLine(), equals('Invalid server response:'));
+ expectLater(pub.nextErrLine(), equals(json.stringify(body)));
pub.shouldExit(1);
});
integration('upload form is missing fields', () {
var server = new ScheduledServer();
- d.credentialsFile(server, 'access token').create();
- var pub = startPublish(server);
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server);
confirmPublish(pub);
var body = {'url': 'http://example.com/upload'};
handleUploadForm(server, body);
- expect(pub.nextErrLine(), completion(equals('Invalid server response:')));
- expect(pub.nextErrLine(), completion(equals(json.stringify(body))));
+ expectLater(pub.nextErrLine(), equals('Invalid server response:'));
+ expectLater(pub.nextErrLine(), equals(json.stringify(body)));
pub.shouldExit(1);
});
integration('upload form fields is not a map', () {
var server = new ScheduledServer();
- d.credentialsFile(server, 'access token').create();
- var pub = startPublish(server);
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server);
confirmPublish(pub);
var body = {'url': 'http://example.com/upload', 'fields': 12};
handleUploadForm(server, body);
- expect(pub.nextErrLine(), completion(equals('Invalid server response:')));
- expect(pub.nextErrLine(), completion(equals(json.stringify(body))));
+ expectLater(pub.nextErrLine(), equals('Invalid server response:'));
+ expectLater(pub.nextErrLine(), equals(json.stringify(body)));
pub.shouldExit(1);
});
integration('upload form fields has a non-string value', () {
var server = new ScheduledServer();
- d.credentialsFile(server, 'access token').create();
- var pub = startPublish(server);
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server);
confirmPublish(pub);
@@ -284,141 +278,137 @@ main() {
'fields': {'field': 12}
};
handleUploadForm(server, body);
- expect(pub.nextErrLine(), completion(equals('Invalid server response:')));
- expect(pub.nextErrLine(), completion(equals(json.stringify(body))));
+ expectLater(pub.nextErrLine(), equals('Invalid server response:'));
+ expectLater(pub.nextErrLine(), equals(json.stringify(body)));
pub.shouldExit(1);
});
integration('cloud storage upload provides an error', () {
var server = new ScheduledServer();
- d.credentialsFile(server, 'access token').create();
- var pub = startPublish(server);
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server);
confirmPublish(pub);
handleUploadForm(server);
- server.handle('POST', '/upload', (request) {
+ server.handle('POST', '/upload', (request, response) {
return drainStream(request).then((_) {
- request.response.statusCode = 400;
- request.response.headers.contentType =
- new ContentType('application', 'xml');
- request.response.write('<Error><Message>Your request sucked.'
+ response.statusCode = 400;
+ response.headers.contentType = new ContentType('application', 'xml');
+ response.write('<Error><Message>Your request sucked.'
'</Message></Error>');
- request.response.close();
+ response.close();
});
});
// TODO(nweiz): This should use the server's error message once the client
// can parse the XML.
- expect(pub.nextErrLine(),
- completion(equals('Failed to upload the package.')));
+ expectLater(pub.nextErrLine(), equals('Failed to upload the package.'));
pub.shouldExit(1);
});
integration("cloud storage upload doesn't redirect", () {
var server = new ScheduledServer();
- d.credentialsFile(server, 'access token').create();
- var pub = startPublish(server);
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server);
confirmPublish(pub);
handleUploadForm(server);
- server.handle('POST', '/upload', (request) {
+ server.handle('POST', '/upload', (request, response) {
return drainStream(request).then((_) {
// Don't set the location header.
- request.response.close();
+ response.close();
});
});
- expect(pub.nextErrLine(),
- completion(equals('Failed to upload the package.')));
+ expectLater(pub.nextErrLine(), equals('Failed to upload the package.'));
pub.shouldExit(1);
});
integration('package creation provides an error', () {
var server = new ScheduledServer();
- d.credentialsFile(server, 'access token').create();
- var pub = startPublish(server);
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server);
confirmPublish(pub);
handleUploadForm(server);
handleUpload(server);
- server.handle('GET', '/create', (request) {
- request.response.statusCode = 400;
- request.response.write(json.stringify({
+ server.handle('GET', '/create', (request, response) {
+ response.statusCode = 400;
+ response.write(json.stringify({
'error': {'message': 'Your package was too boring.'}
}));
- request.response.close();
+ response.close();
});
- expect(pub.nextErrLine(),
- completion(equals('Your package was too boring.')));
+ expectLater(pub.nextErrLine(), equals('Your package was too boring.'));
pub.shouldExit(1);
});
integration('package creation provides invalid JSON', () {
var server = new ScheduledServer();
- d.credentialsFile(server, 'access token').create();
- var pub = startPublish(server);
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server);
confirmPublish(pub);
handleUploadForm(server);
handleUpload(server);
- server.handle('GET', '/create', (request) {
- request.response.write('{not json');
- request.response.close();
+ server.handle('GET', '/create', (request, response) {
+ response.write('{not json');
+ response.close();
});
- expect(pub.nextErrLine(), completion(equals('Invalid server response:')));
- expect(pub.nextErrLine(), completion(equals('{not json')));
+ expectLater(pub.nextErrLine(), equals('Invalid server response:'));
+ expectLater(pub.nextErrLine(), equals('{not json'));
pub.shouldExit(1);
});
integration('package creation provides a malformed error', () {
var server = new ScheduledServer();
- d.credentialsFile(server, 'access token').create();
- var pub = startPublish(server);
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server);
confirmPublish(pub);
handleUploadForm(server);
handleUpload(server);
var body = {'error': 'Your package was too boring.'};
- server.handle('GET', '/create', (request) {
- request.response.statusCode = 400;
- request.response.write(json.stringify(body));
- request.response.close();
+ server.handle('GET', '/create', (request, response) {
+ response.statusCode = 400;
+ response.write(json.stringify(body));
+ response.close();
});
- expect(pub.nextErrLine(), completion(equals('Invalid server response:')));
- expect(pub.nextErrLine(), completion(equals(json.stringify(body))));
+ expectLater(pub.nextErrLine(), equals('Invalid server response:'));
+ expectLater(pub.nextErrLine(), equals(json.stringify(body)));
pub.shouldExit(1);
});
integration('package creation provides a malformed success', () {
var server = new ScheduledServer();
- d.credentialsFile(server, 'access token').create();
- var pub = startPublish(server);
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server);
confirmPublish(pub);
handleUploadForm(server);
handleUpload(server);
var body = {'success': 'Your package was awesome.'};
- server.handle('GET', '/create', (request) {
- request.response.write(json.stringify(body));
- request.response.close();
+ server.handle('GET', '/create', (request, response) {
+ response.write(json.stringify(body));
+ response.close();
});
- expect(pub.nextErrLine(), completion(equals('Invalid server response:')));
- expect(pub.nextErrLine(), completion(equals(json.stringify(body))));
+ expectLater(pub.nextErrLine(), equals('Invalid server response:'));
+ expectLater(pub.nextErrLine(), equals(json.stringify(body)));
pub.shouldExit(1);
});
group('--force', () {
- setUp(() => d.validPackage.create());
+ setUp(() => normalPackage.scheduleCreate());
integration('cannot be combined with --dry-run', () {
schedulePub(args: ['lish', '--force', '--dry-run'],
@@ -428,64 +418,64 @@ main() {
integration('publishes if there are no warnings or errors', () {
var server = new ScheduledServer();
- d.credentialsFile(server, 'access token').create();
- var pub = startPublish(server, args: ['--force']);
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server, args: ['--force']);
handleUploadForm(server);
handleUpload(server);
- server.handle('GET', '/create', (request) {
- request.response.write(json.stringify({
+ server.handle('GET', '/create', (request, response) {
+ response.write(json.stringify({
'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
}));
- request.response.close();
+ response.close();
});
pub.shouldExit(0);
- expect(pub.remainingStdout(), completion(contains(
- 'Package test_pkg 1.0.0 uploaded!')));
+ expectLater(pub.remainingStdout(), contains(
+ 'Package test_pkg 1.0.0 uploaded!'));
});
integration('publishes if there are warnings', () {
- var pkg = packageMap("test_pkg", "1.0.0");
+ var pkg = package("test_pkg", "1.0.0");
pkg["author"] = "Nathan Weizenbaum";
- d.dir(appPath, [d.pubspec(pkg)]).create();
+ dir(appPath, [pubspec(pkg)]).scheduleCreate();
var server = new ScheduledServer();
- d.credentialsFile(server, 'access token').create();
- var pub = startPublish(server, args: ['--force']);
+ credentialsFile(server, 'access token').scheduleCreate();
+ var pub = startPubLish(server, args: ['--force']);
handleUploadForm(server);
handleUpload(server);
- server.handle('GET', '/create', (request) {
- request.response.write(json.stringify({
+ server.handle('GET', '/create', (request, response) {
+ response.write(json.stringify({
'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
}));
- request.response.close();
+ response.close();
});
pub.shouldExit(0);
- expect(pub.remainingStderr(), completion(contains(
+ expectLater(pub.remainingStderr(), contains(
'Suggestions:\n* Author "Nathan Weizenbaum" in pubspec.yaml'
' should have an email address\n'
- ' (e.g. "name <email>").')));
- expect(pub.remainingStdout(), completion(contains(
- 'Package test_pkg 1.0.0 uploaded!')));
+ ' (e.g. "name <email>").'));
+ expectLater(pub.remainingStdout(), contains(
+ 'Package test_pkg 1.0.0 uploaded!'));
});
integration('does not publish if there are errors', () {
- var pkg = packageMap("test_pkg", "1.0.0");
+ var pkg = package("test_pkg", "1.0.0");
pkg.remove("homepage");
- d.dir(appPath, [d.pubspec(pkg)]).create();
+ dir(appPath, [pubspec(pkg)]).scheduleCreate();
var server = new ScheduledServer();
- var pub = startPublish(server, args: ['--force']);
+ var pub = startPubLish(server, args: ['--force']);
pub.shouldExit(0);
- expect(pub.remainingStderr(), completion(contains(
+ expectLater(pub.remainingStderr(), contains(
"Sorry, your package is missing a requirement and can't be "
- "published yet.")));
+ "published yet."));
});
});
}
« no previous file with comments | « utils/tests/pub/pub_cache_test.dart ('k') | utils/tests/pub/pub_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698