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

Unified Diff: generated/googleapis/test/cloudfunctions/v1_test.dart

Issue 2779563003: Api-roll 47: 2017-03-27 (Closed)
Patch Set: Created 3 years, 9 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: generated/googleapis/test/cloudfunctions/v1_test.dart
diff --git a/generated/googleapis/test/cloudfunctions/v1_test.dart b/generated/googleapis/test/cloudfunctions/v1_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5064c0f83ccd8f32ab447aa48c299c88dbaed8e3
--- /dev/null
+++ b/generated/googleapis/test/cloudfunctions/v1_test.dart
@@ -0,0 +1,211 @@
+library googleapis.cloudfunctions.v1.test;
+
+import "dart:core" as core;
+import "dart:collection" as collection;
+import "dart:async" as async;
+import "dart:convert" as convert;
+
+import 'package:http/http.dart' as http;
+import 'package:http/testing.dart' as http_testing;
+import 'package:unittest/unittest.dart' as unittest;
+
+import 'package:googleapis/cloudfunctions/v1.dart' as api;
+
+class HttpServerMock extends http.BaseClient {
+ core.Function _callback;
+ core.bool _expectJson;
+
+ void register(core.Function callback, core.bool expectJson) {
+ _callback = callback;
+ _expectJson = expectJson;
+ }
+
+ async.Future<http.StreamedResponse> send(http.BaseRequest request) {
+ if (_expectJson) {
+ return request.finalize()
+ .transform(convert.UTF8.decoder)
+ .join('')
+ .then((core.String jsonString) {
+ if (jsonString.isEmpty) {
+ return _callback(request, null);
+ } else {
+ return _callback(request, convert.JSON.decode(jsonString));
+ }
+ });
+ } else {
+ var stream = request.finalize();
+ if (stream == null) {
+ return _callback(request, []);
+ } else {
+ return stream.toBytes().then((data) {
+ return _callback(request, data);
+ });
+ }
+ }
+ }
+}
+
+http.StreamedResponse stringResponse(
+ core.int status, core.Map headers, core.String body) {
+ var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]);
+ return new http.StreamedResponse(stream, status, headers: headers);
+}
+
+buildUnnamed97() {
+ var o = new core.Map<core.String, core.String>();
+ o["x"] = "foo";
+ o["y"] = "foo";
+ return o;
+}
+
+checkUnnamed97(core.Map<core.String, core.String> o) {
+ unittest.expect(o, unittest.hasLength(2));
+ unittest.expect(o["x"], unittest.equals('foo'));
+ unittest.expect(o["y"], unittest.equals('foo'));
+}
+
+buildUnnamed98() {
+ var o = new core.Map<core.String, core.Object>();
+ o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
+ o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
+ return o;
+}
+
+checkUnnamed98(core.Map<core.String, core.Object> o) {
+ unittest.expect(o, unittest.hasLength(2));
+ var casted1 = (o["x"]) as core.Map; unittest.expect(casted1, unittest.hasLength(3)); unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); unittest.expect(casted1["bool"], unittest.equals(true)); unittest.expect(casted1["string"], unittest.equals('foo'));
+ var casted2 = (o["y"]) as core.Map; unittest.expect(casted2, unittest.hasLength(3)); unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); unittest.expect(casted2["bool"], unittest.equals(true)); unittest.expect(casted2["string"], unittest.equals('foo'));
+}
+
+core.int buildCounterLocation = 0;
+buildLocation() {
+ var o = new api.Location();
+ buildCounterLocation++;
+ if (buildCounterLocation < 3) {
+ o.labels = buildUnnamed97();
+ o.locationId = "foo";
+ o.metadata = buildUnnamed98();
+ o.name = "foo";
+ }
+ buildCounterLocation--;
+ return o;
+}
+
+checkLocation(api.Location o) {
+ buildCounterLocation++;
+ if (buildCounterLocation < 3) {
+ checkUnnamed97(o.labels);
+ unittest.expect(o.locationId, unittest.equals('foo'));
+ checkUnnamed98(o.metadata);
+ unittest.expect(o.name, unittest.equals('foo'));
+ }
+ buildCounterLocation--;
+}
+
+buildUnnamed99() {
+ var o = new core.Map<core.String, core.Object>();
+ o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
+ o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
+ return o;
+}
+
+checkUnnamed99(core.Map<core.String, core.Object> o) {
+ unittest.expect(o, unittest.hasLength(2));
+ var casted3 = (o["x"]) as core.Map; unittest.expect(casted3, unittest.hasLength(3)); unittest.expect(casted3["list"], unittest.equals([1, 2, 3])); unittest.expect(casted3["bool"], unittest.equals(true)); unittest.expect(casted3["string"], unittest.equals('foo'));
+ var casted4 = (o["y"]) as core.Map; unittest.expect(casted4, unittest.hasLength(3)); unittest.expect(casted4["list"], unittest.equals([1, 2, 3])); unittest.expect(casted4["bool"], unittest.equals(true)); unittest.expect(casted4["string"], unittest.equals('foo'));
+}
+
+core.int buildCounterOperationMetadataV1Beta2 = 0;
+buildOperationMetadataV1Beta2() {
+ var o = new api.OperationMetadataV1Beta2();
+ buildCounterOperationMetadataV1Beta2++;
+ if (buildCounterOperationMetadataV1Beta2 < 3) {
+ o.request = buildUnnamed99();
+ o.target = "foo";
+ o.type = "foo";
+ }
+ buildCounterOperationMetadataV1Beta2--;
+ return o;
+}
+
+checkOperationMetadataV1Beta2(api.OperationMetadataV1Beta2 o) {
+ buildCounterOperationMetadataV1Beta2++;
+ if (buildCounterOperationMetadataV1Beta2 < 3) {
+ checkUnnamed99(o.request);
+ unittest.expect(o.target, unittest.equals('foo'));
+ unittest.expect(o.type, unittest.equals('foo'));
+ }
+ buildCounterOperationMetadataV1Beta2--;
+}
+
+
+main() {
+ unittest.group("obj-schema-Location", () {
+ unittest.test("to-json--from-json", () {
+ var o = buildLocation();
+ var od = new api.Location.fromJson(o.toJson());
+ checkLocation(od);
+ });
+ });
+
+
+ unittest.group("obj-schema-OperationMetadataV1Beta2", () {
+ unittest.test("to-json--from-json", () {
+ var o = buildOperationMetadataV1Beta2();
+ var od = new api.OperationMetadataV1Beta2.fromJson(o.toJson());
+ checkOperationMetadataV1Beta2(od);
+ });
+ });
+
+
+ unittest.group("resource-ProjectsLocationsResourceApi", () {
+ unittest.test("method--get", () {
+
+ var mock = new HttpServerMock();
+ api.ProjectsLocationsResourceApi res = new api.CloudfunctionsApi(mock).projects.locations;
+ var arg_name = "foo";
+ mock.register(unittest.expectAsync((http.BaseRequest req, json) {
+ var path = (req.url).path;
+ var pathOffset = 0;
+ var index;
+ var subPart;
+ unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
+ pathOffset += 1;
+ unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/"));
+ pathOffset += 3;
+ // NOTE: We cannot test reserved expansions due to the inability to reverse the operation;
+
+ var query = (req.url).query;
+ var queryOffset = 0;
+ var queryMap = {};
+ addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
+ parseBool(n) {
+ if (n == "true") return true;
+ if (n == "false") return false;
+ if (n == null) return null;
+ throw new core.ArgumentError("Invalid boolean: $n");
+ }
+ if (query.length > 0) {
+ for (var part in query.split("&")) {
+ var keyvalue = part.split("=");
+ addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.decodeQueryComponent(keyvalue[1]));
+ }
+ }
+
+
+ var h = {
+ "content-type" : "application/json; charset=utf-8",
+ };
+ var resp = convert.JSON.encode(buildLocation());
+ return new async.Future.value(stringResponse(200, h, resp));
+ }), true);
+ res.get(arg_name).then(unittest.expectAsync(((api.Location response) {
+ checkLocation(response);
+ })));
+ });
+
+ });
+
+
+}
+
« no previous file with comments | « generated/googleapis/test/clouddebugger/v2_test.dart ('k') | generated/googleapis/test/cloudkms/v1_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698