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

Side by Side Diff: sdk/lib/_internal/pub_generated/test/pub_uploader_test.dart

Issue 887223007: Revert "Use native async/await support in pub." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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) 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 pub_uploader_test; 5 library pub_uploader_test;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:scheduled_test/scheduled_process.dart'; 9 import 'package:scheduled_test/scheduled_process.dart';
10 import 'package:scheduled_test/scheduled_server.dart'; 10 import 'package:scheduled_test/scheduled_server.dart';
(...skipping 14 matching lines...) Expand all
25 (defaults to "https://pub.dartlang.org") 25 (defaults to "https://pub.dartlang.org")
26 26
27 --package The package whose uploaders will be modified. 27 --package The package whose uploaders will be modified.
28 (defaults to the current package) 28 (defaults to the current package)
29 29
30 Run "pub help" to see global options. 30 Run "pub help" to see global options.
31 See http://dartlang.org/tools/pub/cmd/pub-uploader.html for detailed documentati on. 31 See http://dartlang.org/tools/pub/cmd/pub-uploader.html for detailed documentati on.
32 '''; 32 ''';
33 33
34 ScheduledProcess startPubUploader(ScheduledServer server, List<String> args) { 34 ScheduledProcess startPubUploader(ScheduledServer server, List<String> args) {
35 var tokenEndpoint = server.url.then((url) => 35 var tokenEndpoint =
36 url.resolve('/token').toString()); 36 server.url.then((url) => url.resolve('/token').toString());
37 args = flatten(['uploader', '--server', tokenEndpoint, args]); 37 args = flatten(['uploader', '--server', tokenEndpoint, args]);
38 return startPub(args: args, tokenEndpoint: tokenEndpoint); 38 return startPub(args: args, tokenEndpoint: tokenEndpoint);
39 } 39 }
40 40
41 main() { 41 main() {
42 initConfig(); 42 initConfig();
43 group('displays usage', () { 43 group('displays usage', () {
44 integration('when run with no arguments', () { 44 integration('when run with no arguments', () {
45 schedulePub(args: ['uploader'], 45 schedulePub(
46 output: USAGE_STRING, exitCode: exit_codes.USAGE); 46 args: ['uploader'],
47 output: USAGE_STRING,
48 exitCode: exit_codes.USAGE);
47 }); 49 });
48 50
49 integration('when run with only a command', () { 51 integration('when run with only a command', () {
50 schedulePub(args: ['uploader', 'add'], 52 schedulePub(
51 output: USAGE_STRING, exitCode: exit_codes.USAGE); 53 args: ['uploader', 'add'],
54 output: USAGE_STRING,
55 exitCode: exit_codes.USAGE);
52 }); 56 });
53 57
54 integration('when run with an invalid command', () { 58 integration('when run with an invalid command', () {
55 schedulePub(args: ['uploader', 'foo', 'email'], 59 schedulePub(
56 output: USAGE_STRING, exitCode: exit_codes.USAGE); 60 args: ['uploader', 'foo', 'email'],
61 output: USAGE_STRING,
62 exitCode: exit_codes.USAGE);
57 }); 63 });
58 }); 64 });
59 65
60 integration('adds an uploader', () { 66 integration('adds an uploader', () {
61 var server = new ScheduledServer(); 67 var server = new ScheduledServer();
62 d.credentialsFile(server, 'access token').create(); 68 d.credentialsFile(server, 'access token').create();
63 var pub = startPubUploader(server, ['--package', 'pkg', 'add', 'email']); 69 var pub = startPubUploader(server, ['--package', 'pkg', 'add', 'email']);
64 70
65 server.handle('POST', '/api/packages/pkg/uploaders', (request) { 71 server.handle('POST', '/api/packages/pkg/uploaders', (request) {
66 return request.readAsString().then((body) { 72 return request.readAsString().then((body) {
67 expect(body, equals('email=email')); 73 expect(body, equals('email=email'));
68 74
69 return new shelf.Response.ok(JSON.encode({ 75 return new shelf.Response.ok(JSON.encode({
70 'success': {'message': 'Good job!'} 76 'success': {
71 }), headers: {'content-type': 'application/json'}); 77 'message': 'Good job!'
78 }
79 }), headers: {
80 'content-type': 'application/json'
81 });
72 }); 82 });
73 }); 83 });
74 84
75 pub.stdout.expect('Good job!'); 85 pub.stdout.expect('Good job!');
76 pub.shouldExit(exit_codes.SUCCESS); 86 pub.shouldExit(exit_codes.SUCCESS);
77 }); 87 });
78 88
79 integration('removes an uploader', () { 89 integration('removes an uploader', () {
80 var server = new ScheduledServer(); 90 var server = new ScheduledServer();
81 d.credentialsFile(server, 'access token').create(); 91 d.credentialsFile(server, 'access token').create();
82 var pub = startPubUploader(server, ['--package', 'pkg', 'remove', 'email']); 92 var pub = startPubUploader(server, ['--package', 'pkg', 'remove', 'email']);
83 93
84 server.handle('DELETE', '/api/packages/pkg/uploaders/email', (request) { 94 server.handle('DELETE', '/api/packages/pkg/uploaders/email', (request) {
85 return new shelf.Response.ok(JSON.encode({ 95 return new shelf.Response.ok(JSON.encode({
86 'success': {'message': 'Good job!'} 96 'success': {
87 }), headers: {'content-type': 'application/json'}); 97 'message': 'Good job!'
98 }
99 }), headers: {
100 'content-type': 'application/json'
101 });
88 }); 102 });
89 103
90 pub.stdout.expect('Good job!'); 104 pub.stdout.expect('Good job!');
91 pub.shouldExit(exit_codes.SUCCESS); 105 pub.shouldExit(exit_codes.SUCCESS);
92 }); 106 });
93 107
94 integration('defaults to the current package', () { 108 integration('defaults to the current package', () {
95 d.validPackage.create(); 109 d.validPackage.create();
96 110
97 var server = new ScheduledServer(); 111 var server = new ScheduledServer();
98 d.credentialsFile(server, 'access token').create(); 112 d.credentialsFile(server, 'access token').create();
99 var pub = startPubUploader(server, ['add', 'email']); 113 var pub = startPubUploader(server, ['add', 'email']);
100 114
101 server.handle('POST', '/api/packages/test_pkg/uploaders', (request) { 115 server.handle('POST', '/api/packages/test_pkg/uploaders', (request) {
102 return new shelf.Response.ok(JSON.encode({ 116 return new shelf.Response.ok(JSON.encode({
103 'success': {'message': 'Good job!'} 117 'success': {
104 }), headers: {'content-type': 'application/json'}); 118 'message': 'Good job!'
119 }
120 }), headers: {
121 'content-type': 'application/json'
122 });
105 }); 123 });
106 124
107 pub.stdout.expect('Good job!'); 125 pub.stdout.expect('Good job!');
108 pub.shouldExit(exit_codes.SUCCESS); 126 pub.shouldExit(exit_codes.SUCCESS);
109 }); 127 });
110 128
111 integration('add provides an error', () { 129 integration('add provides an error', () {
112 var server = new ScheduledServer(); 130 var server = new ScheduledServer();
113 d.credentialsFile(server, 'access token').create(); 131 d.credentialsFile(server, 'access token').create();
114 var pub = startPubUploader(server, ['--package', 'pkg', 'add', 'email']); 132 var pub = startPubUploader(server, ['--package', 'pkg', 'add', 'email']);
115 133
116 server.handle('POST', '/api/packages/pkg/uploaders', (request) { 134 server.handle('POST', '/api/packages/pkg/uploaders', (request) {
117 return new shelf.Response(400, 135 return new shelf.Response(400, body: JSON.encode({
118 body: JSON.encode({'error': {'message': 'Bad job!'}}), 136 'error': {
119 headers: {'content-type': 'application/json'}); 137 'message': 'Bad job!'
138 }
139 }), headers: {
140 'content-type': 'application/json'
141 });
120 }); 142 });
121 143
122 pub.stderr.expect('Bad job!'); 144 pub.stderr.expect('Bad job!');
123 pub.shouldExit(1); 145 pub.shouldExit(1);
124 }); 146 });
125 147
126 integration('remove provides an error', () { 148 integration('remove provides an error', () {
127 var server = new ScheduledServer(); 149 var server = new ScheduledServer();
128 d.credentialsFile(server, 'access token').create(); 150 d.credentialsFile(server, 'access token').create();
129 var pub = startPubUploader(server, 151 var pub =
130 ['--package', 'pkg', 'remove', 'e/mail']); 152 startPubUploader(server, ['--package', 'pkg', 'remove', 'e/mail']);
131 153
132 server.handle('DELETE', '/api/packages/pkg/uploaders/e%2Fmail', (request) { 154 server.handle('DELETE', '/api/packages/pkg/uploaders/e%2Fmail', (request) {
133 return new shelf.Response(400, 155 return new shelf.Response(400, body: JSON.encode({
134 body: JSON.encode({'error': {'message': 'Bad job!'}}), 156 'error': {
135 headers: {'content-type': 'application/json'}); 157 'message': 'Bad job!'
158 }
159 }), headers: {
160 'content-type': 'application/json'
161 });
136 }); 162 });
137 163
138 pub.stderr.expect('Bad job!'); 164 pub.stderr.expect('Bad job!');
139 pub.shouldExit(1); 165 pub.shouldExit(1);
140 }); 166 });
141 167
142 integration('add provides invalid JSON', () { 168 integration('add provides invalid JSON', () {
143 var server = new ScheduledServer(); 169 var server = new ScheduledServer();
144 d.credentialsFile(server, 'access token').create(); 170 d.credentialsFile(server, 'access token').create();
145 var pub = startPubUploader(server, ['--package', 'pkg', 'add', 'email']); 171 var pub = startPubUploader(server, ['--package', 'pkg', 'add', 'email']);
146 172
147 server.handle('POST', '/api/packages/pkg/uploaders', 173 server.handle(
174 'POST',
175 '/api/packages/pkg/uploaders',
148 (request) => new shelf.Response.ok("{not json")); 176 (request) => new shelf.Response.ok("{not json"));
149 177
150 pub.stderr.expect(emitsLines( 178 pub.stderr.expect(emitsLines('Invalid server response:\n' '{not json'));
151 'Invalid server response:\n'
152 '{not json'));
153 pub.shouldExit(1); 179 pub.shouldExit(1);
154 }); 180 });
155 181
156 integration('remove provides invalid JSON', () { 182 integration('remove provides invalid JSON', () {
157 var server = new ScheduledServer(); 183 var server = new ScheduledServer();
158 d.credentialsFile(server, 'access token').create(); 184 d.credentialsFile(server, 'access token').create();
159 var pub = startPubUploader(server, ['--package', 'pkg', 'remove', 'email']); 185 var pub = startPubUploader(server, ['--package', 'pkg', 'remove', 'email']);
160 186
161 server.handle('DELETE', '/api/packages/pkg/uploaders/email', 187 server.handle(
188 'DELETE',
189 '/api/packages/pkg/uploaders/email',
162 (request) => new shelf.Response.ok("{not json")); 190 (request) => new shelf.Response.ok("{not json"));
163 191
164 pub.stderr.expect(emitsLines( 192 pub.stderr.expect(emitsLines('Invalid server response:\n' '{not json'));
165 'Invalid server response:\n'
166 '{not json'));
167 pub.shouldExit(1); 193 pub.shouldExit(1);
168 }); 194 });
169 } 195 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub_generated/test/pub_test.dart ('k') | sdk/lib/_internal/pub_generated/test/pubspec_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698