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

Side by Side Diff: utils/tests/pub/pub_lish_test.dart

Issue 12226077: add --preview flag to publish command (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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
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 pub_lish_test; 5 library pub_lish_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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 expectLater(pub.nextLine(), equals( 74 expectLater(pub.nextLine(), equals(
75 'Looks great! Are you ready to upload your package (y/n)?' 75 'Looks great! Are you ready to upload your package (y/n)?'
76 ' Package test_pkg 1.0.0 uploaded!')); 76 ' Package test_pkg 1.0.0 uploaded!'));
77 pub.shouldExit(0); 77 pub.shouldExit(0);
78 }); 78 });
79 79
80 // TODO(nweiz): Once a multipart/form-data parser in Dart exists, we should 80 // TODO(nweiz): Once a multipart/form-data parser in Dart exists, we should
81 // test that "pub lish" chooses the correct files to publish. 81 // test that "pub lish" chooses the correct files to publish.
82 82
83 integration('package validation has an error', () { 83 integration('package validation has an error', () {
84 var package = package("test_pkg", "1.0.0"); 84 var pkg = package("test_pkg", "1.0.0");
85 package.remove("homepage"); 85 pkg.remove("homepage");
86 dir(appPath, [pubspec(package)]).scheduleCreate(); 86 dir(appPath, [pubspec(pkg)]).scheduleCreate();
87 87
88 var server = new ScheduledServer(); 88 var server = new ScheduledServer();
89 var pub = startPubLish(server); 89 var pub = startPubLish(server);
90 90
91 pub.shouldExit(1); 91 pub.shouldExit(1);
92 expectLater(pub.remainingStderr(), 92 expectLater(pub.remainingStderr(),
93 contains("Sorry, your package is missing a requirement and can't be " 93 contains("Sorry, your package is missing a requirement and can't be "
94 "published yet.")); 94 "published yet."));
95 }); 95 });
96 96
97 integration('preview package validation has a warning', () {
98 var pkg = package("test_pkg", "1.0.0");
99 pkg["author"] = "Nathan Weizenbaum";
100 dir(appPath, [pubspec(pkg)]).scheduleCreate();
101
102 var server = new ScheduledServer();
103 var lishArgs = new List();
104 lishArgs.add("--dry-run");
Bob Nystrom 2013/02/11 18:44:37 Eek, Java! :) Just do: startPubLish(server, args
keertip 2013/02/11 23:57:31 Done.
105 var pub = startPubLish(server,args: lishArgs);
Bob Nystrom 2013/02/11 18:44:37 Space after ",".
keertip 2013/02/11 23:57:31 Done.
106
107 pub.shouldExit(0);
Bob Nystrom 2013/02/11 18:44:37 Do we want a zero exit code for this? It might be
108 expectLater(pub.remainingStderr(),
109 contains('Suggestions:\n* Author "Nathan Weizenbaum" in pubspec.yaml '
110 'should have an email address\n (e.g. "name <email>").\n\n'
Bob Nystrom 2013/02/11 18:44:37 Extra leading space here. Also, I'd split it at th
111 'Package has 1 warning.'));
112 });
113
114 integration('preview package validation has no warnings', () {
115 var pkg = package("test_pkg", "1.0.0");
116 pkg["author"] = "Nathan Weizenbaum <nweiz@google.com>";
117 dir(appPath, [pubspec(pkg)]).scheduleCreate();
118
119 var server = new ScheduledServer();
120 var lishArgs = new List();
121 lishArgs.add("--dry-run");
122 var pub = startPubLish(server,args: lishArgs);
Bob Nystrom 2013/02/11 18:44:37 lishArgs -> ['--dry-run']
keertip 2013/02/11 23:57:31 Done.
123
124 pub.shouldExit(0);
125 expectLater(pub.remainingStderr(),
126 contains('Package has 0 warnings.'));
127 });
128
97 integration('package validation has a warning and is canceled', () { 129 integration('package validation has a warning and is canceled', () {
98 var package = package("test_pkg", "1.0.0"); 130 var pkg = package("test_pkg", "1.0.0");
99 package["author"] = "Nathan Weizenbaum"; 131 pkg["author"] = "Nathan Weizenbaum";
100 dir(appPath, [pubspec(package)]).scheduleCreate(); 132 dir(appPath, [pubspec(pkg)]).scheduleCreate();
101 133
102 var server = new ScheduledServer(); 134 var server = new ScheduledServer();
103 var pub = startPubLish(server); 135 var pub = startPubLish(server);
104 136
105 pub.writeLine("n"); 137 pub.writeLine("n");
106 pub.shouldExit(1); 138 pub.shouldExit(1);
107 expectLater(pub.remainingStderr(), contains("Package upload canceled.")); 139 expectLater(pub.remainingStderr(), contains("Package upload canceled."));
108 }); 140 });
109 141
110 integration('package validation has a warning and continues', () { 142 integration('package validation has a warning and continues', () {
111 var package = package("test_pkg", "1.0.0"); 143 var pkg = package("test_pkg", "1.0.0");
112 package["author"] = "Nathan Weizenbaum"; 144 pkg["author"] = "Nathan Weizenbaum";
113 dir(appPath, [pubspec(package)]).scheduleCreate(); 145 dir(appPath, [pubspec(pkg)]).scheduleCreate();
114 146
115 var server = new ScheduledServer(); 147 var server = new ScheduledServer();
116 credentialsFile(server, 'access token').scheduleCreate(); 148 credentialsFile(server, 'access token').scheduleCreate();
117 var pub = startPubLish(server); 149 var pub = startPubLish(server);
118 pub.writeLine("y"); 150 pub.writeLine("y");
119 handleUploadForm(server); 151 handleUploadForm(server);
120 handleUpload(server); 152 handleUpload(server);
121 153
122 server.handle('GET', '/create', (request, response) { 154 server.handle('GET', '/create', (request, response) {
123 response.outputStream.writeString(json.stringify({ 155 response.outputStream.writeString(json.stringify({
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 server.handle('GET', '/create', (request, response) { 402 server.handle('GET', '/create', (request, response) {
371 response.outputStream.writeString(json.stringify(body)); 403 response.outputStream.writeString(json.stringify(body));
372 response.outputStream.close(); 404 response.outputStream.close();
373 }); 405 });
374 406
375 expectLater(pub.nextErrLine(), equals('Invalid server response:')); 407 expectLater(pub.nextErrLine(), equals('Invalid server response:'));
376 expectLater(pub.nextErrLine(), equals(json.stringify(body))); 408 expectLater(pub.nextErrLine(), equals(json.stringify(body)));
377 pub.shouldExit(1); 409 pub.shouldExit(1);
378 }); 410 });
379 } 411 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698