OLD | NEW |
1 library googleapis_beta.replicapoolupdater.v1beta1.test; | 1 library googleapis_beta.replicapoolupdater.v1beta1.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:unittest/unittest.dart' as unittest; |
(...skipping 22 matching lines...) Expand all Loading... |
33 unittest.expect(o.update, unittest.equals('foo')); | 33 unittest.expect(o.update, unittest.equals('foo')); |
34 } | 34 } |
35 buildCounterInsertResponse--; | 35 buildCounterInsertResponse--; |
36 } | 36 } |
37 | 37 |
38 core.int buildCounterInstanceUpdate = 0; | 38 core.int buildCounterInstanceUpdate = 0; |
39 buildInstanceUpdate() { | 39 buildInstanceUpdate() { |
40 var o = new api.InstanceUpdate(); | 40 var o = new api.InstanceUpdate(); |
41 buildCounterInstanceUpdate++; | 41 buildCounterInstanceUpdate++; |
42 if (buildCounterInstanceUpdate < 3) { | 42 if (buildCounterInstanceUpdate < 3) { |
43 o.instanceName = "foo"; | 43 o.instance = "foo"; |
44 o.state = "foo"; | 44 o.state = "foo"; |
| 45 o.status = "foo"; |
45 } | 46 } |
46 buildCounterInstanceUpdate--; | 47 buildCounterInstanceUpdate--; |
47 return o; | 48 return o; |
48 } | 49 } |
49 | 50 |
50 checkInstanceUpdate(api.InstanceUpdate o) { | 51 checkInstanceUpdate(api.InstanceUpdate o) { |
51 buildCounterInstanceUpdate++; | 52 buildCounterInstanceUpdate++; |
52 if (buildCounterInstanceUpdate < 3) { | 53 if (buildCounterInstanceUpdate < 3) { |
53 unittest.expect(o.instanceName, unittest.equals('foo')); | 54 unittest.expect(o.instance, unittest.equals('foo')); |
54 unittest.expect(o.state, unittest.equals('foo')); | 55 unittest.expect(o.state, unittest.equals('foo')); |
| 56 unittest.expect(o.status, unittest.equals('foo')); |
55 } | 57 } |
56 buildCounterInstanceUpdate--; | 58 buildCounterInstanceUpdate--; |
57 } | 59 } |
58 | 60 |
59 buildUnnamed1402() { | 61 buildUnnamed1305() { |
60 var o = new core.List<api.InstanceUpdate>(); | 62 var o = new core.List<api.InstanceUpdate>(); |
61 o.add(buildInstanceUpdate()); | 63 o.add(buildInstanceUpdate()); |
62 o.add(buildInstanceUpdate()); | 64 o.add(buildInstanceUpdate()); |
63 return o; | 65 return o; |
64 } | 66 } |
65 | 67 |
66 checkUnnamed1402(core.List<api.InstanceUpdate> o) { | 68 checkUnnamed1305(core.List<api.InstanceUpdate> o) { |
67 unittest.expect(o, unittest.hasLength(2)); | 69 unittest.expect(o, unittest.hasLength(2)); |
68 checkInstanceUpdate(o[0]); | 70 checkInstanceUpdate(o[0]); |
69 checkInstanceUpdate(o[1]); | 71 checkInstanceUpdate(o[1]); |
70 } | 72 } |
71 | 73 |
| 74 core.int buildCounterInstanceUpdateList = 0; |
| 75 buildInstanceUpdateList() { |
| 76 var o = new api.InstanceUpdateList(); |
| 77 buildCounterInstanceUpdateList++; |
| 78 if (buildCounterInstanceUpdateList < 3) { |
| 79 o.items = buildUnnamed1305(); |
| 80 o.kind = "foo"; |
| 81 o.nextPageToken = "foo"; |
| 82 o.selfLink = "foo"; |
| 83 } |
| 84 buildCounterInstanceUpdateList--; |
| 85 return o; |
| 86 } |
| 87 |
| 88 checkInstanceUpdateList(api.InstanceUpdateList o) { |
| 89 buildCounterInstanceUpdateList++; |
| 90 if (buildCounterInstanceUpdateList < 3) { |
| 91 checkUnnamed1305(o.items); |
| 92 unittest.expect(o.kind, unittest.equals('foo')); |
| 93 unittest.expect(o.nextPageToken, unittest.equals('foo')); |
| 94 unittest.expect(o.selfLink, unittest.equals('foo')); |
| 95 } |
| 96 buildCounterInstanceUpdateList--; |
| 97 } |
| 98 |
72 core.int buildCounterUpdate = 0; | 99 core.int buildCounterUpdate = 0; |
73 buildUpdate() { | 100 buildUpdate() { |
74 var o = new api.Update(); | 101 var o = new api.Update(); |
75 buildCounterUpdate++; | 102 buildCounterUpdate++; |
76 if (buildCounterUpdate < 3) { | 103 if (buildCounterUpdate < 3) { |
77 o.creationTimestamp = "foo"; | 104 o.creationTimestamp = "foo"; |
78 o.details = "foo"; | 105 o.details = "foo"; |
79 o.handle = "foo"; | 106 o.handle = "foo"; |
| 107 o.id = "foo"; |
| 108 o.instanceGroupManager = "foo"; |
80 o.instanceTemplate = "foo"; | 109 o.instanceTemplate = "foo"; |
81 o.instanceUpdates = buildUnnamed1402(); | |
82 o.kind = "foo"; | 110 o.kind = "foo"; |
83 o.policy = buildUpdatePolicy(); | 111 o.policy = buildUpdatePolicy(); |
| 112 o.progress = 42; |
84 o.selfLink = "foo"; | 113 o.selfLink = "foo"; |
85 o.state = "foo"; | 114 o.state = "foo"; |
| 115 o.status = "foo"; |
| 116 o.statusMessage = "foo"; |
86 o.targetState = "foo"; | 117 o.targetState = "foo"; |
87 o.user = "foo"; | 118 o.user = "foo"; |
88 } | 119 } |
89 buildCounterUpdate--; | 120 buildCounterUpdate--; |
90 return o; | 121 return o; |
91 } | 122 } |
92 | 123 |
93 checkUpdate(api.Update o) { | 124 checkUpdate(api.Update o) { |
94 buildCounterUpdate++; | 125 buildCounterUpdate++; |
95 if (buildCounterUpdate < 3) { | 126 if (buildCounterUpdate < 3) { |
96 unittest.expect(o.creationTimestamp, unittest.equals('foo')); | 127 unittest.expect(o.creationTimestamp, unittest.equals('foo')); |
97 unittest.expect(o.details, unittest.equals('foo')); | 128 unittest.expect(o.details, unittest.equals('foo')); |
98 unittest.expect(o.handle, unittest.equals('foo')); | 129 unittest.expect(o.handle, unittest.equals('foo')); |
| 130 unittest.expect(o.id, unittest.equals('foo')); |
| 131 unittest.expect(o.instanceGroupManager, unittest.equals('foo')); |
99 unittest.expect(o.instanceTemplate, unittest.equals('foo')); | 132 unittest.expect(o.instanceTemplate, unittest.equals('foo')); |
100 checkUnnamed1402(o.instanceUpdates); | |
101 unittest.expect(o.kind, unittest.equals('foo')); | 133 unittest.expect(o.kind, unittest.equals('foo')); |
102 checkUpdatePolicy(o.policy); | 134 checkUpdatePolicy(o.policy); |
| 135 unittest.expect(o.progress, unittest.equals(42)); |
103 unittest.expect(o.selfLink, unittest.equals('foo')); | 136 unittest.expect(o.selfLink, unittest.equals('foo')); |
104 unittest.expect(o.state, unittest.equals('foo')); | 137 unittest.expect(o.state, unittest.equals('foo')); |
| 138 unittest.expect(o.status, unittest.equals('foo')); |
| 139 unittest.expect(o.statusMessage, unittest.equals('foo')); |
105 unittest.expect(o.targetState, unittest.equals('foo')); | 140 unittest.expect(o.targetState, unittest.equals('foo')); |
106 unittest.expect(o.user, unittest.equals('foo')); | 141 unittest.expect(o.user, unittest.equals('foo')); |
107 } | 142 } |
108 buildCounterUpdate--; | 143 buildCounterUpdate--; |
109 } | 144 } |
110 | 145 |
111 buildUnnamed1403() { | 146 buildUnnamed1306() { |
112 var o = new core.List<api.Update>(); | 147 var o = new core.List<api.Update>(); |
113 o.add(buildUpdate()); | 148 o.add(buildUpdate()); |
114 o.add(buildUpdate()); | 149 o.add(buildUpdate()); |
115 return o; | 150 return o; |
116 } | 151 } |
117 | 152 |
118 checkUnnamed1403(core.List<api.Update> o) { | 153 checkUnnamed1306(core.List<api.Update> o) { |
119 unittest.expect(o, unittest.hasLength(2)); | 154 unittest.expect(o, unittest.hasLength(2)); |
120 checkUpdate(o[0]); | 155 checkUpdate(o[0]); |
121 checkUpdate(o[1]); | 156 checkUpdate(o[1]); |
122 } | 157 } |
123 | 158 |
124 core.int buildCounterUpdateList = 0; | 159 core.int buildCounterUpdateList = 0; |
125 buildUpdateList() { | 160 buildUpdateList() { |
126 var o = new api.UpdateList(); | 161 var o = new api.UpdateList(); |
127 buildCounterUpdateList++; | 162 buildCounterUpdateList++; |
128 if (buildCounterUpdateList < 3) { | 163 if (buildCounterUpdateList < 3) { |
129 o.items = buildUnnamed1403(); | 164 o.items = buildUnnamed1306(); |
| 165 o.kind = "foo"; |
130 o.nextPageToken = "foo"; | 166 o.nextPageToken = "foo"; |
| 167 o.selfLink = "foo"; |
131 } | 168 } |
132 buildCounterUpdateList--; | 169 buildCounterUpdateList--; |
133 return o; | 170 return o; |
134 } | 171 } |
135 | 172 |
136 checkUpdateList(api.UpdateList o) { | 173 checkUpdateList(api.UpdateList o) { |
137 buildCounterUpdateList++; | 174 buildCounterUpdateList++; |
138 if (buildCounterUpdateList < 3) { | 175 if (buildCounterUpdateList < 3) { |
139 checkUnnamed1403(o.items); | 176 checkUnnamed1306(o.items); |
| 177 unittest.expect(o.kind, unittest.equals('foo')); |
140 unittest.expect(o.nextPageToken, unittest.equals('foo')); | 178 unittest.expect(o.nextPageToken, unittest.equals('foo')); |
| 179 unittest.expect(o.selfLink, unittest.equals('foo')); |
141 } | 180 } |
142 buildCounterUpdateList--; | 181 buildCounterUpdateList--; |
143 } | 182 } |
144 | 183 |
145 core.int buildCounterUpdatePolicy = 0; | 184 core.int buildCounterUpdatePolicy = 0; |
146 buildUpdatePolicy() { | 185 buildUpdatePolicy() { |
147 var o = new api.UpdatePolicy(); | 186 var o = new api.UpdatePolicy(); |
148 buildCounterUpdatePolicy++; | 187 buildCounterUpdatePolicy++; |
149 if (buildCounterUpdatePolicy < 3) { | 188 if (buildCounterUpdatePolicy < 3) { |
150 o.canary = buildUpdatePolicyCanary(); | 189 o.canary = buildUpdatePolicyCanary(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 236 |
198 unittest.group("obj-schema-InstanceUpdate", () { | 237 unittest.group("obj-schema-InstanceUpdate", () { |
199 unittest.test("to-json--from-json", () { | 238 unittest.test("to-json--from-json", () { |
200 var o = buildInstanceUpdate(); | 239 var o = buildInstanceUpdate(); |
201 var od = new api.InstanceUpdate.fromJson(o.toJson()); | 240 var od = new api.InstanceUpdate.fromJson(o.toJson()); |
202 checkInstanceUpdate(od); | 241 checkInstanceUpdate(od); |
203 }); | 242 }); |
204 }); | 243 }); |
205 | 244 |
206 | 245 |
| 246 unittest.group("obj-schema-InstanceUpdateList", () { |
| 247 unittest.test("to-json--from-json", () { |
| 248 var o = buildInstanceUpdateList(); |
| 249 var od = new api.InstanceUpdateList.fromJson(o.toJson()); |
| 250 checkInstanceUpdateList(od); |
| 251 }); |
| 252 }); |
| 253 |
| 254 |
207 unittest.group("obj-schema-Update", () { | 255 unittest.group("obj-schema-Update", () { |
208 unittest.test("to-json--from-json", () { | 256 unittest.test("to-json--from-json", () { |
209 var o = buildUpdate(); | 257 var o = buildUpdate(); |
210 var od = new api.Update.fromJson(o.toJson()); | 258 var od = new api.Update.fromJson(o.toJson()); |
211 checkUpdate(od); | 259 checkUpdate(od); |
212 }); | 260 }); |
213 }); | 261 }); |
214 | 262 |
215 | 263 |
216 unittest.group("obj-schema-UpdateList", () { | 264 unittest.group("obj-schema-UpdateList", () { |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 "content-type" : "application/json; charset=utf-8", | 466 "content-type" : "application/json; charset=utf-8", |
419 }; | 467 }; |
420 var resp = convert.JSON.encode(buildUpdateList()); | 468 var resp = convert.JSON.encode(buildUpdateList()); |
421 return new async.Future.value(common_test.stringResponse(200, h, resp)); | 469 return new async.Future.value(common_test.stringResponse(200, h, resp)); |
422 }), true); | 470 }), true); |
423 res.list(arg_project, arg_zone, arg_instanceGroupManager, maxResults: arg_
maxResults, pageToken: arg_pageToken).then(unittest.expectAsync(((api.UpdateList
response) { | 471 res.list(arg_project, arg_zone, arg_instanceGroupManager, maxResults: arg_
maxResults, pageToken: arg_pageToken).then(unittest.expectAsync(((api.UpdateList
response) { |
424 checkUpdateList(response); | 472 checkUpdateList(response); |
425 }))); | 473 }))); |
426 }); | 474 }); |
427 | 475 |
| 476 unittest.test("method--listInstanceUpdates", () { |
| 477 |
| 478 var mock = new common_test.HttpServerMock(); |
| 479 api.UpdatesResourceApi res = new api.ReplicapoolupdaterApi(mock).updates; |
| 480 var arg_project = "foo"; |
| 481 var arg_zone = "foo"; |
| 482 var arg_instanceGroupManager = "foo"; |
| 483 var arg_update = "foo"; |
| 484 var arg_maxResults = 42; |
| 485 var arg_pageToken = "foo"; |
| 486 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 487 var path = (req.url).path; |
| 488 var pathOffset = 0; |
| 489 var index; |
| 490 var subPart; |
| 491 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 492 pathOffset += 1; |
| 493 |
| 494 var query = (req.url).query; |
| 495 var queryOffset = 0; |
| 496 var queryMap = {}; |
| 497 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 498 parseBool(n) { |
| 499 if (n == "true") return true; |
| 500 if (n == "false") return false; |
| 501 if (n == null) return null; |
| 502 throw new core.ArgumentError("Invalid boolean: $n"); |
| 503 } |
| 504 if (query.length > 0) { |
| 505 for (var part in query.split("&")) { |
| 506 var keyvalue = part.split("="); |
| 507 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 508 } |
| 509 } |
| 510 unittest.expect(core.int.parse(queryMap["maxResults"].first), unittest.e
quals(arg_maxResults)); |
| 511 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); |
| 512 |
| 513 |
| 514 var h = { |
| 515 "content-type" : "application/json; charset=utf-8", |
| 516 }; |
| 517 var resp = convert.JSON.encode(buildInstanceUpdateList()); |
| 518 return new async.Future.value(common_test.stringResponse(200, h, resp)); |
| 519 }), true); |
| 520 res.listInstanceUpdates(arg_project, arg_zone, arg_instanceGroupManager, a
rg_update, maxResults: arg_maxResults, pageToken: arg_pageToken).then(unittest.e
xpectAsync(((api.InstanceUpdateList response) { |
| 521 checkInstanceUpdateList(response); |
| 522 }))); |
| 523 }); |
| 524 |
428 unittest.test("method--pause", () { | 525 unittest.test("method--pause", () { |
429 | 526 |
430 var mock = new common_test.HttpServerMock(); | 527 var mock = new common_test.HttpServerMock(); |
431 api.UpdatesResourceApi res = new api.ReplicapoolupdaterApi(mock).updates; | 528 api.UpdatesResourceApi res = new api.ReplicapoolupdaterApi(mock).updates; |
432 var arg_project = "foo"; | 529 var arg_project = "foo"; |
433 var arg_zone = "foo"; | 530 var arg_zone = "foo"; |
434 var arg_instanceGroupManager = "foo"; | 531 var arg_instanceGroupManager = "foo"; |
435 var arg_update = "foo"; | 532 var arg_update = "foo"; |
436 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 533 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
437 var path = (req.url).path; | 534 var path = (req.url).path; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 return new async.Future.value(common_test.stringResponse(200, h, resp)); | 649 return new async.Future.value(common_test.stringResponse(200, h, resp)); |
553 }), true); | 650 }), true); |
554 res.rollforward(arg_project, arg_zone, arg_instanceGroupManager, arg_updat
e).then(unittest.expectAsync((_) {})); | 651 res.rollforward(arg_project, arg_zone, arg_instanceGroupManager, arg_updat
e).then(unittest.expectAsync((_) {})); |
555 }); | 652 }); |
556 | 653 |
557 }); | 654 }); |
558 | 655 |
559 | 656 |
560 } | 657 } |
561 | 658 |
OLD | NEW |