| Index: sdk/lib/_internal/pub/test/serve/web_socket/returns_errors_on_bad_commands_test.dart
|
| diff --git a/sdk/lib/_internal/pub/test/serve/web_socket/returns_errors_on_bad_commands_test.dart b/sdk/lib/_internal/pub/test/serve/web_socket/returns_errors_on_bad_commands_test.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d6452f63ea8c726d2b8b0965776565961d095a87
|
| --- /dev/null
|
| +++ b/sdk/lib/_internal/pub/test/serve/web_socket/returns_errors_on_bad_commands_test.dart
|
| @@ -0,0 +1,55 @@
|
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.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_tests;
|
| +
|
| +import 'package:scheduled_test/scheduled_test.dart';
|
| +import '../../descriptor.dart' as d;
|
| +import '../../test_pub.dart';
|
| +import '../utils.dart';
|
| +
|
| +main() {
|
| + initConfig();
|
| + integration("handles bad commands", () {
|
| + d.dir(appPath, [
|
| + d.appPubspec()
|
| + ]).create();
|
| +
|
| + startPubServe();
|
| +
|
| + webSocketShouldReply(
|
| + "not even valid json",
|
| + equals({"error": '"not even valid json" is not valid JSON: '
|
| + 'Unexpected character at 0: \'not even valid json\''}),
|
| + encodeRequest: false);
|
| +
|
| + webSocketShouldReply(
|
| + {"command": "wat"},
|
| + equals({"error": 'Unknown command "wat".'}));
|
| +
|
| + webSocketShouldReply(
|
| + ["not", "a", "map"],
|
| + equals({"error": 'Command must be a JSON map. '
|
| + 'Got: ["not","a","map"].'}));
|
| +
|
| + webSocketShouldReply(
|
| + {"wat": "there's no command"},
|
| + equals({"error": 'Missing command name. '
|
| + 'Got: {"wat":"there\'s no command"}.'}));
|
| +
|
| + webSocketShouldReply(
|
| + {"command": "urlToAsset", "path": 123},
|
| + equals({"error": '"path" must be a string. Got: 123.'}));
|
| +
|
| + webSocketShouldReply(
|
| + {"command": "assetToUrl", "package": 123, "path": "index.html"},
|
| + equals({"error": '"package" must be a string. Got: 123.'}));
|
| +
|
| + webSocketShouldReply(
|
| + {"command": "assetToUrl", "package": "foo", "path": 123},
|
| + equals({"error": '"path" must be a string. Got: 123.'}));
|
| +
|
| + endPubServe();
|
| + });
|
| +}
|
|
|