OLD | NEW |
1 library googleapis.cloudfunctions.v1.test; | 1 library googleapis.cloudfunctions.v1.test; |
2 | 2 |
3 import "dart:core" as core; | 3 import "dart:core" as core; |
4 import "dart:collection" as collection; | 4 import "dart:collection" as collection; |
5 import "dart:async" as async; | 5 import "dart:async" as async; |
6 import "dart:convert" as convert; | 6 import "dart:convert" as convert; |
7 | 7 |
8 import 'package:http/http.dart' as http; | 8 import 'package:http/http.dart' as http; |
9 import 'package:http/testing.dart' as http_testing; | 9 import 'package:http/testing.dart' as http_testing; |
10 import 'package:unittest/unittest.dart' as unittest; | 10 import 'package:test/test.dart' as unittest; |
11 | 11 |
12 import 'package:googleapis/cloudfunctions/v1.dart' as api; | 12 import 'package:googleapis/cloudfunctions/v1.dart' as api; |
13 | 13 |
14 class HttpServerMock extends http.BaseClient { | 14 class HttpServerMock extends http.BaseClient { |
15 core.Function _callback; | 15 core.Function _callback; |
16 core.bool _expectJson; | 16 core.bool _expectJson; |
17 | 17 |
18 void register(core.Function callback, core.bool expectJson) { | 18 void register(core.Function callback, core.bool expectJson) { |
19 _callback = callback; | 19 _callback = callback; |
20 _expectJson = expectJson; | 20 _expectJson = expectJson; |
(...skipping 18 matching lines...) Expand all Loading... |
39 } else { | 39 } else { |
40 return stream.toBytes().then((data) { | 40 return stream.toBytes().then((data) { |
41 return _callback(request, data); | 41 return _callback(request, data); |
42 }); | 42 }); |
43 } | 43 } |
44 } | 44 } |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
48 http.StreamedResponse stringResponse( | 48 http.StreamedResponse stringResponse( |
49 core.int status, core.Map headers, core.String body) { | 49 core.int status, core.Map<core.String, core.String> headers, core.String bod
y) { |
50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); | 50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); |
51 return new http.StreamedResponse(stream, status, headers: headers); | 51 return new http.StreamedResponse(stream, status, headers: headers); |
52 } | 52 } |
53 | 53 |
54 buildUnnamed97() { | 54 buildUnnamed99() { |
55 var o = new core.Map<core.String, core.Object>(); | 55 var o = new core.Map<core.String, core.Object>(); |
56 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 56 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; |
57 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 57 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; |
58 return o; | 58 return o; |
59 } | 59 } |
60 | 60 |
61 checkUnnamed97(core.Map<core.String, core.Object> o) { | 61 checkUnnamed99(core.Map<core.String, core.Object> o) { |
62 unittest.expect(o, unittest.hasLength(2)); | 62 unittest.expect(o, unittest.hasLength(2)); |
63 var casted1 = (o["x"]) as core.Map; unittest.expect(casted1, unittest.hasLengt
h(3)); unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); unittest.ex
pect(casted1["bool"], unittest.equals(true)); unittest.expect(casted1["string"],
unittest.equals('foo')); | 63 var casted1 = (o["x"]) as core.Map; unittest.expect(casted1, unittest.hasLengt
h(3)); unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); unittest.ex
pect(casted1["bool"], unittest.equals(true)); unittest.expect(casted1["string"],
unittest.equals('foo')); |
64 var casted2 = (o["y"]) as core.Map; unittest.expect(casted2, unittest.hasLengt
h(3)); unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); unittest.ex
pect(casted2["bool"], unittest.equals(true)); unittest.expect(casted2["string"],
unittest.equals('foo')); | 64 var casted2 = (o["y"]) as core.Map; unittest.expect(casted2, unittest.hasLengt
h(3)); unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); unittest.ex
pect(casted2["bool"], unittest.equals(true)); unittest.expect(casted2["string"],
unittest.equals('foo')); |
65 } | 65 } |
66 | 66 |
67 core.int buildCounterOperationMetadataV1Beta2 = 0; | 67 core.int buildCounterOperationMetadataV1Beta2 = 0; |
68 buildOperationMetadataV1Beta2() { | 68 buildOperationMetadataV1Beta2() { |
69 var o = new api.OperationMetadataV1Beta2(); | 69 var o = new api.OperationMetadataV1Beta2(); |
70 buildCounterOperationMetadataV1Beta2++; | 70 buildCounterOperationMetadataV1Beta2++; |
71 if (buildCounterOperationMetadataV1Beta2 < 3) { | 71 if (buildCounterOperationMetadataV1Beta2 < 3) { |
72 o.request = buildUnnamed97(); | 72 o.request = buildUnnamed99(); |
73 o.target = "foo"; | 73 o.target = "foo"; |
74 o.type = "foo"; | 74 o.type = "foo"; |
75 } | 75 } |
76 buildCounterOperationMetadataV1Beta2--; | 76 buildCounterOperationMetadataV1Beta2--; |
77 return o; | 77 return o; |
78 } | 78 } |
79 | 79 |
80 checkOperationMetadataV1Beta2(api.OperationMetadataV1Beta2 o) { | 80 checkOperationMetadataV1Beta2(api.OperationMetadataV1Beta2 o) { |
81 buildCounterOperationMetadataV1Beta2++; | 81 buildCounterOperationMetadataV1Beta2++; |
82 if (buildCounterOperationMetadataV1Beta2 < 3) { | 82 if (buildCounterOperationMetadataV1Beta2 < 3) { |
83 checkUnnamed97(o.request); | 83 checkUnnamed99(o.request); |
84 unittest.expect(o.target, unittest.equals('foo')); | 84 unittest.expect(o.target, unittest.equals('foo')); |
85 unittest.expect(o.type, unittest.equals('foo')); | 85 unittest.expect(o.type, unittest.equals('foo')); |
86 } | 86 } |
87 buildCounterOperationMetadataV1Beta2--; | 87 buildCounterOperationMetadataV1Beta2--; |
88 } | 88 } |
89 | 89 |
90 | 90 |
91 main() { | 91 main() { |
92 unittest.group("obj-schema-OperationMetadataV1Beta2", () { | 92 unittest.group("obj-schema-OperationMetadataV1Beta2", () { |
93 unittest.test("to-json--from-json", () { | 93 unittest.test("to-json--from-json", () { |
94 var o = buildOperationMetadataV1Beta2(); | 94 var o = buildOperationMetadataV1Beta2(); |
95 var od = new api.OperationMetadataV1Beta2.fromJson(o.toJson()); | 95 var od = new api.OperationMetadataV1Beta2.fromJson(o.toJson()); |
96 checkOperationMetadataV1Beta2(od); | 96 checkOperationMetadataV1Beta2(od); |
97 }); | 97 }); |
98 }); | 98 }); |
99 | 99 |
100 | 100 |
101 } | 101 } |
102 | 102 |
OLD | NEW |