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

Unified Diff: sdk/lib/_internal/pub_generated/test/pub_uploader_test.dart

Issue 657673002: Regenerate pub sources. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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
Index: sdk/lib/_internal/pub_generated/test/pub_uploader_test.dart
diff --git a/sdk/lib/_internal/pub_generated/test/pub_uploader_test.dart b/sdk/lib/_internal/pub_generated/test/pub_uploader_test.dart
index db294c0a9d02771e7cf9fe5ceef6f83ab762b19e..19ff839f89d0d9eab558f030cea927f2ab276d4f 100644
--- a/sdk/lib/_internal/pub_generated/test/pub_uploader_test.dart
+++ b/sdk/lib/_internal/pub_generated/test/pub_uploader_test.dart
@@ -1,13 +1,21 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
library pub_uploader_test;
+
import 'dart:convert';
+
import 'package:scheduled_test/scheduled_process.dart';
import 'package:scheduled_test/scheduled_server.dart';
import 'package:scheduled_test/scheduled_test.dart';
import 'package:shelf/shelf.dart' as shelf;
+
import '../lib/src/exit_codes.dart' as exit_codes;
import '../lib/src/utils.dart';
import 'descriptor.dart' as d;
import 'test_pub.dart';
+
final USAGE_STRING = '''
Manage uploaders for a package on pub.dartlang.org.
@@ -22,12 +30,14 @@ Usage: pub uploader [options] {add/remove} <email>
Run "pub help" to see global options.
See http://dartlang.org/tools/pub/cmd/pub-uploader.html for detailed documentation.
''';
+
ScheduledProcess startPubUploader(ScheduledServer server, List<String> args) {
var tokenEndpoint =
server.url.then((url) => url.resolve('/token').toString());
args = flatten(['uploader', '--server', tokenEndpoint, args]);
return startPub(args: args, tokenEndpoint: tokenEndpoint);
}
+
main() {
initConfig();
group('displays usage', () {
@@ -37,12 +47,14 @@ main() {
output: USAGE_STRING,
exitCode: exit_codes.USAGE);
});
+
integration('when run with only a command', () {
schedulePub(
args: ['uploader', 'add'],
output: USAGE_STRING,
exitCode: exit_codes.USAGE);
});
+
integration('when run with an invalid command', () {
schedulePub(
args: ['uploader', 'foo', 'email'],
@@ -50,13 +62,16 @@ main() {
exitCode: exit_codes.USAGE);
});
});
+
integration('adds an uploader', () {
var server = new ScheduledServer();
d.credentialsFile(server, 'access token').create();
var pub = startPubUploader(server, ['--package', 'pkg', 'add', 'email']);
+
server.handle('POST', '/api/packages/pkg/uploaders', (request) {
return request.readAsString().then((body) {
expect(body, equals('email=email'));
+
return new shelf.Response.ok(JSON.encode({
'success': {
'message': 'Good job!'
@@ -66,13 +81,16 @@ main() {
});
});
});
+
pub.stdout.expect('Good job!');
pub.shouldExit(exit_codes.SUCCESS);
});
+
integration('removes an uploader', () {
var server = new ScheduledServer();
d.credentialsFile(server, 'access token').create();
var pub = startPubUploader(server, ['--package', 'pkg', 'remove', 'email']);
+
server.handle('DELETE', '/api/packages/pkg/uploaders/email', (request) {
return new shelf.Response.ok(JSON.encode({
'success': {
@@ -82,14 +100,18 @@ main() {
'content-type': 'application/json'
});
});
+
pub.stdout.expect('Good job!');
pub.shouldExit(exit_codes.SUCCESS);
});
+
integration('defaults to the current package', () {
d.validPackage.create();
+
var server = new ScheduledServer();
d.credentialsFile(server, 'access token').create();
var pub = startPubUploader(server, ['add', 'email']);
+
server.handle('POST', '/api/packages/test_pkg/uploaders', (request) {
return new shelf.Response.ok(JSON.encode({
'success': {
@@ -99,13 +121,16 @@ main() {
'content-type': 'application/json'
});
});
+
pub.stdout.expect('Good job!');
pub.shouldExit(exit_codes.SUCCESS);
});
+
integration('add provides an error', () {
var server = new ScheduledServer();
d.credentialsFile(server, 'access token').create();
var pub = startPubUploader(server, ['--package', 'pkg', 'add', 'email']);
+
server.handle('POST', '/api/packages/pkg/uploaders', (request) {
return new shelf.Response(400, body: JSON.encode({
'error': {
@@ -115,14 +140,17 @@ main() {
'content-type': 'application/json'
});
});
+
pub.stderr.expect('Bad job!');
pub.shouldExit(1);
});
+
integration('remove provides an error', () {
var server = new ScheduledServer();
d.credentialsFile(server, 'access token').create();
var pub =
startPubUploader(server, ['--package', 'pkg', 'remove', 'e/mail']);
+
server.handle('DELETE', '/api/packages/pkg/uploaders/e%2Fmail', (request) {
return new shelf.Response(400, body: JSON.encode({
'error': {
@@ -132,28 +160,35 @@ main() {
'content-type': 'application/json'
});
});
+
pub.stderr.expect('Bad job!');
pub.shouldExit(1);
});
+
integration('add provides invalid JSON', () {
var server = new ScheduledServer();
d.credentialsFile(server, 'access token').create();
var pub = startPubUploader(server, ['--package', 'pkg', 'add', 'email']);
+
server.handle(
'POST',
'/api/packages/pkg/uploaders',
(request) => new shelf.Response.ok("{not json"));
+
pub.stderr.expect(emitsLines('Invalid server response:\n' '{not json'));
pub.shouldExit(1);
});
+
integration('remove provides invalid JSON', () {
var server = new ScheduledServer();
d.credentialsFile(server, 'access token').create();
var pub = startPubUploader(server, ['--package', 'pkg', 'remove', 'email']);
+
server.handle(
'DELETE',
'/api/packages/pkg/uploaders/email',
(request) => new shelf.Response.ok("{not json"));
+
pub.stderr.expect(emitsLines('Invalid server response:\n' '{not json'));
pub.shouldExit(1);
});
« 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