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

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

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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
« no previous file with comments | « utils/tests/pub/oauth2_test.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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'; 8 import 'dart:json';
9 9
10 import 'test_pub.dart'; 10 import 'test_pub.dart';
11 import '../../../pkg/unittest/lib/unittest.dart'; 11 import '../../../pkg/unittest/lib/unittest.dart';
12 import '../../pub/io.dart'; 12 import '../../pub/io.dart';
13 13
14 void handleUploadForm(ScheduledServer server, [Map body]) { 14 void handleUploadForm(ScheduledServer server, [Map body]) {
15 server.handle('GET', '/packages/versions/new.json', (request, response) { 15 server.handle('GET', '/packages/versions/new.json', (request, response) {
16 return server.url.transform((url) { 16 return server.url.then((url) {
17 expect(request.headers.value('authorization'), 17 expect(request.headers.value('authorization'),
18 equals('Bearer access token')); 18 equals('Bearer access token'));
19 19
20 if (body == null) { 20 if (body == null) {
21 body = { 21 body = {
22 'url': url.resolve('/upload').toString(), 22 'url': url.resolve('/upload').toString(),
23 'fields': { 23 'fields': {
24 'field1': 'value1', 24 'field1': 'value1',
25 'field2': 'value2' 25 'field2': 'value2'
26 } 26 }
27 }; 27 };
28 } 28 }
29 29
30 response.headers.contentType = new ContentType("application", "json"); 30 response.headers.contentType = new ContentType("application", "json");
31 response.outputStream.writeString(JSON.stringify(body)); 31 response.outputStream.writeString(JSON.stringify(body));
32 response.outputStream.close(); 32 response.outputStream.close();
33 }); 33 });
34 }); 34 });
35 } 35 }
36 36
37 void handleUpload(ScheduledServer server) { 37 void handleUpload(ScheduledServer server) {
38 server.handle('POST', '/upload', (request, response) { 38 server.handle('POST', '/upload', (request, response) {
39 // TODO(nweiz): Once a multipart/form-data parser in Dart exists, validate 39 // TODO(nweiz): Once a multipart/form-data parser in Dart exists, validate
40 // that the request body is correctly formatted. See issue 6952. 40 // that the request body is correctly formatted. See issue 6952.
41 return server.url.transform((url) { 41 return server.url.then((url) {
42 response.statusCode = 302; 42 response.statusCode = 302;
43 response.headers.set('location', url.resolve('/create').toString()); 43 response.headers.set('location', url.resolve('/create').toString());
44 response.outputStream.close(); 44 response.outputStream.close();
45 }); 45 });
46 }); 46 });
47 } 47 }
48 48
49 main() { 49 main() {
50 setUp(() => normalPackage.scheduleCreate()); 50 setUp(() => normalPackage.scheduleCreate());
51 51
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 response.outputStream.close(); 397 response.outputStream.close();
398 }); 398 });
399 399
400 expectLater(pub.nextErrLine(), equals('Invalid server response:')); 400 expectLater(pub.nextErrLine(), equals('Invalid server response:'));
401 expectLater(pub.nextErrLine(), equals(JSON.stringify(body))); 401 expectLater(pub.nextErrLine(), equals(JSON.stringify(body)));
402 pub.shouldExit(1); 402 pub.shouldExit(1);
403 403
404 run(); 404 run();
405 }); 405 });
406 } 406 }
OLDNEW
« no previous file with comments | « utils/tests/pub/oauth2_test.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698