updated generated code
diff --git a/generated/googleapis/test/run/v1_test.dart b/generated/googleapis/test/run/v1_test.dart new file mode 100644 index 0000000..4c759c7 --- /dev/null +++ b/generated/googleapis/test/run/v1_test.dart
@@ -0,0 +1,184 @@ +library googleapis.run.v1.test; + +import "dart:core" as core; +import "dart:async" as async; +import "dart:convert" as convert; + +import 'package:http/http.dart' as http; +import 'package:test/test.dart' as unittest; + +import 'package:googleapis/run/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<core.String, core.String> headers, core.String body) { + var stream = new async.Stream.fromIterable([convert.utf8.encode(body)]); + return new http.StreamedResponse(stream, status, headers: headers); +} + +buildUnnamed677() { + var o = new core.Map<core.String, core.String>(); + o["x"] = "foo"; + o["y"] = "foo"; + return o; +} + +checkUnnamed677(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')); +} + +buildUnnamed678() { + 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; +} + +checkUnnamed678(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.displayName = "foo"; + o.labels = buildUnnamed677(); + o.locationId = "foo"; + o.metadata = buildUnnamed678(); + o.name = "foo"; + } + buildCounterLocation--; + return o; +} + +checkLocation(api.Location o) { + buildCounterLocation++; + if (buildCounterLocation < 3) { + unittest.expect(o.displayName, unittest.equals('foo')); + checkUnnamed677(o.labels); + unittest.expect(o.locationId, unittest.equals('foo')); + checkUnnamed678(o.metadata); + unittest.expect(o.name, unittest.equals('foo')); + } + buildCounterLocation--; +} + +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("resource-ProjectsLocationsResourceApi", () { + unittest.test("method--get", () { + var mock = new HttpServerMock(); + api.ProjectsLocationsResourceApi res = + new api.RunApi(mock).projects.locations; + var arg_name = "foo"; + var arg_$fields = "foo"; + mock.register(unittest.expectAsync2((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 = <core.String, core.List<core.String>>{}; + 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])); + } + } + unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); + + 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, $fields: arg_$fields) + .then(unittest.expectAsync1(((response) { + checkLocation(response); + }))); + }); + }); +}