OLD | NEW |
| (Empty) |
1 library googleapis_beta.replicapool.v1beta1.test; | |
2 | |
3 import "dart:core" as core; | |
4 import "dart:collection" as collection; | |
5 import "dart:async" as async; | |
6 import "dart:convert" as convert; | |
7 | |
8 import 'package:http/http.dart' as http; | |
9 import 'package:http/testing.dart' as http_testing; | |
10 import 'package:unittest/unittest.dart' as unittest; | |
11 import 'package:googleapis_beta/common/common.dart' as common; | |
12 import 'package:googleapis_beta/src/common_internal.dart' as common_internal; | |
13 import '../common/common_internal_test.dart' as common_test; | |
14 | |
15 import 'package:googleapis_beta/replicapool/v1beta1.dart' as api; | |
16 | |
17 | |
18 | |
19 core.int buildCounterAccessConfig = 0; | |
20 buildAccessConfig() { | |
21 var o = new api.AccessConfig(); | |
22 buildCounterAccessConfig++; | |
23 if (buildCounterAccessConfig < 3) { | |
24 o.name = "foo"; | |
25 o.natIp = "foo"; | |
26 o.type = "foo"; | |
27 } | |
28 buildCounterAccessConfig--; | |
29 return o; | |
30 } | |
31 | |
32 checkAccessConfig(api.AccessConfig o) { | |
33 buildCounterAccessConfig++; | |
34 if (buildCounterAccessConfig < 3) { | |
35 unittest.expect(o.name, unittest.equals('foo')); | |
36 unittest.expect(o.natIp, unittest.equals('foo')); | |
37 unittest.expect(o.type, unittest.equals('foo')); | |
38 } | |
39 buildCounterAccessConfig--; | |
40 } | |
41 | |
42 buildUnnamed1059() { | |
43 var o = new core.List<core.String>(); | |
44 o.add("foo"); | |
45 o.add("foo"); | |
46 return o; | |
47 } | |
48 | |
49 checkUnnamed1059(core.List<core.String> o) { | |
50 unittest.expect(o, unittest.hasLength(2)); | |
51 unittest.expect(o[0], unittest.equals('foo')); | |
52 unittest.expect(o[1], unittest.equals('foo')); | |
53 } | |
54 | |
55 buildUnnamed1060() { | |
56 var o = new core.List<api.EnvVariable>(); | |
57 o.add(buildEnvVariable()); | |
58 o.add(buildEnvVariable()); | |
59 return o; | |
60 } | |
61 | |
62 checkUnnamed1060(core.List<api.EnvVariable> o) { | |
63 unittest.expect(o, unittest.hasLength(2)); | |
64 checkEnvVariable(o[0]); | |
65 checkEnvVariable(o[1]); | |
66 } | |
67 | |
68 core.int buildCounterAction = 0; | |
69 buildAction() { | |
70 var o = new api.Action(); | |
71 buildCounterAction++; | |
72 if (buildCounterAction < 3) { | |
73 o.commands = buildUnnamed1059(); | |
74 o.envVariables = buildUnnamed1060(); | |
75 o.timeoutMilliSeconds = 42; | |
76 } | |
77 buildCounterAction--; | |
78 return o; | |
79 } | |
80 | |
81 checkAction(api.Action o) { | |
82 buildCounterAction++; | |
83 if (buildCounterAction < 3) { | |
84 checkUnnamed1059(o.commands); | |
85 checkUnnamed1060(o.envVariables); | |
86 unittest.expect(o.timeoutMilliSeconds, unittest.equals(42)); | |
87 } | |
88 buildCounterAction--; | |
89 } | |
90 | |
91 core.int buildCounterDiskAttachment = 0; | |
92 buildDiskAttachment() { | |
93 var o = new api.DiskAttachment(); | |
94 buildCounterDiskAttachment++; | |
95 if (buildCounterDiskAttachment < 3) { | |
96 o.deviceName = "foo"; | |
97 o.index = 42; | |
98 } | |
99 buildCounterDiskAttachment--; | |
100 return o; | |
101 } | |
102 | |
103 checkDiskAttachment(api.DiskAttachment o) { | |
104 buildCounterDiskAttachment++; | |
105 if (buildCounterDiskAttachment < 3) { | |
106 unittest.expect(o.deviceName, unittest.equals('foo')); | |
107 unittest.expect(o.index, unittest.equals(42)); | |
108 } | |
109 buildCounterDiskAttachment--; | |
110 } | |
111 | |
112 core.int buildCounterEnvVariable = 0; | |
113 buildEnvVariable() { | |
114 var o = new api.EnvVariable(); | |
115 buildCounterEnvVariable++; | |
116 if (buildCounterEnvVariable < 3) { | |
117 o.hidden = true; | |
118 o.name = "foo"; | |
119 o.value = "foo"; | |
120 } | |
121 buildCounterEnvVariable--; | |
122 return o; | |
123 } | |
124 | |
125 checkEnvVariable(api.EnvVariable o) { | |
126 buildCounterEnvVariable++; | |
127 if (buildCounterEnvVariable < 3) { | |
128 unittest.expect(o.hidden, unittest.isTrue); | |
129 unittest.expect(o.name, unittest.equals('foo')); | |
130 unittest.expect(o.value, unittest.equals('foo')); | |
131 } | |
132 buildCounterEnvVariable--; | |
133 } | |
134 | |
135 core.int buildCounterExistingDisk = 0; | |
136 buildExistingDisk() { | |
137 var o = new api.ExistingDisk(); | |
138 buildCounterExistingDisk++; | |
139 if (buildCounterExistingDisk < 3) { | |
140 o.attachment = buildDiskAttachment(); | |
141 o.source = "foo"; | |
142 } | |
143 buildCounterExistingDisk--; | |
144 return o; | |
145 } | |
146 | |
147 checkExistingDisk(api.ExistingDisk o) { | |
148 buildCounterExistingDisk++; | |
149 if (buildCounterExistingDisk < 3) { | |
150 checkDiskAttachment(o.attachment); | |
151 unittest.expect(o.source, unittest.equals('foo')); | |
152 } | |
153 buildCounterExistingDisk--; | |
154 } | |
155 | |
156 core.int buildCounterHealthCheck = 0; | |
157 buildHealthCheck() { | |
158 var o = new api.HealthCheck(); | |
159 buildCounterHealthCheck++; | |
160 if (buildCounterHealthCheck < 3) { | |
161 o.checkIntervalSec = 42; | |
162 o.description = "foo"; | |
163 o.healthyThreshold = 42; | |
164 o.host = "foo"; | |
165 o.name = "foo"; | |
166 o.path = "foo"; | |
167 o.port = 42; | |
168 o.timeoutSec = 42; | |
169 o.unhealthyThreshold = 42; | |
170 } | |
171 buildCounterHealthCheck--; | |
172 return o; | |
173 } | |
174 | |
175 checkHealthCheck(api.HealthCheck o) { | |
176 buildCounterHealthCheck++; | |
177 if (buildCounterHealthCheck < 3) { | |
178 unittest.expect(o.checkIntervalSec, unittest.equals(42)); | |
179 unittest.expect(o.description, unittest.equals('foo')); | |
180 unittest.expect(o.healthyThreshold, unittest.equals(42)); | |
181 unittest.expect(o.host, unittest.equals('foo')); | |
182 unittest.expect(o.name, unittest.equals('foo')); | |
183 unittest.expect(o.path, unittest.equals('foo')); | |
184 unittest.expect(o.port, unittest.equals(42)); | |
185 unittest.expect(o.timeoutSec, unittest.equals(42)); | |
186 unittest.expect(o.unhealthyThreshold, unittest.equals(42)); | |
187 } | |
188 buildCounterHealthCheck--; | |
189 } | |
190 | |
191 core.int buildCounterLabel = 0; | |
192 buildLabel() { | |
193 var o = new api.Label(); | |
194 buildCounterLabel++; | |
195 if (buildCounterLabel < 3) { | |
196 o.key = "foo"; | |
197 o.value = "foo"; | |
198 } | |
199 buildCounterLabel--; | |
200 return o; | |
201 } | |
202 | |
203 checkLabel(api.Label o) { | |
204 buildCounterLabel++; | |
205 if (buildCounterLabel < 3) { | |
206 unittest.expect(o.key, unittest.equals('foo')); | |
207 unittest.expect(o.value, unittest.equals('foo')); | |
208 } | |
209 buildCounterLabel--; | |
210 } | |
211 | |
212 buildUnnamed1061() { | |
213 var o = new core.List<api.MetadataItem>(); | |
214 o.add(buildMetadataItem()); | |
215 o.add(buildMetadataItem()); | |
216 return o; | |
217 } | |
218 | |
219 checkUnnamed1061(core.List<api.MetadataItem> o) { | |
220 unittest.expect(o, unittest.hasLength(2)); | |
221 checkMetadataItem(o[0]); | |
222 checkMetadataItem(o[1]); | |
223 } | |
224 | |
225 core.int buildCounterMetadata = 0; | |
226 buildMetadata() { | |
227 var o = new api.Metadata(); | |
228 buildCounterMetadata++; | |
229 if (buildCounterMetadata < 3) { | |
230 o.fingerPrint = "foo"; | |
231 o.items = buildUnnamed1061(); | |
232 } | |
233 buildCounterMetadata--; | |
234 return o; | |
235 } | |
236 | |
237 checkMetadata(api.Metadata o) { | |
238 buildCounterMetadata++; | |
239 if (buildCounterMetadata < 3) { | |
240 unittest.expect(o.fingerPrint, unittest.equals('foo')); | |
241 checkUnnamed1061(o.items); | |
242 } | |
243 buildCounterMetadata--; | |
244 } | |
245 | |
246 core.int buildCounterMetadataItem = 0; | |
247 buildMetadataItem() { | |
248 var o = new api.MetadataItem(); | |
249 buildCounterMetadataItem++; | |
250 if (buildCounterMetadataItem < 3) { | |
251 o.key = "foo"; | |
252 o.value = "foo"; | |
253 } | |
254 buildCounterMetadataItem--; | |
255 return o; | |
256 } | |
257 | |
258 checkMetadataItem(api.MetadataItem o) { | |
259 buildCounterMetadataItem++; | |
260 if (buildCounterMetadataItem < 3) { | |
261 unittest.expect(o.key, unittest.equals('foo')); | |
262 unittest.expect(o.value, unittest.equals('foo')); | |
263 } | |
264 buildCounterMetadataItem--; | |
265 } | |
266 | |
267 buildUnnamed1062() { | |
268 var o = new core.List<api.AccessConfig>(); | |
269 o.add(buildAccessConfig()); | |
270 o.add(buildAccessConfig()); | |
271 return o; | |
272 } | |
273 | |
274 checkUnnamed1062(core.List<api.AccessConfig> o) { | |
275 unittest.expect(o, unittest.hasLength(2)); | |
276 checkAccessConfig(o[0]); | |
277 checkAccessConfig(o[1]); | |
278 } | |
279 | |
280 core.int buildCounterNetworkInterface = 0; | |
281 buildNetworkInterface() { | |
282 var o = new api.NetworkInterface(); | |
283 buildCounterNetworkInterface++; | |
284 if (buildCounterNetworkInterface < 3) { | |
285 o.accessConfigs = buildUnnamed1062(); | |
286 o.network = "foo"; | |
287 o.networkIp = "foo"; | |
288 } | |
289 buildCounterNetworkInterface--; | |
290 return o; | |
291 } | |
292 | |
293 checkNetworkInterface(api.NetworkInterface o) { | |
294 buildCounterNetworkInterface++; | |
295 if (buildCounterNetworkInterface < 3) { | |
296 checkUnnamed1062(o.accessConfigs); | |
297 unittest.expect(o.network, unittest.equals('foo')); | |
298 unittest.expect(o.networkIp, unittest.equals('foo')); | |
299 } | |
300 buildCounterNetworkInterface--; | |
301 } | |
302 | |
303 core.int buildCounterNewDisk = 0; | |
304 buildNewDisk() { | |
305 var o = new api.NewDisk(); | |
306 buildCounterNewDisk++; | |
307 if (buildCounterNewDisk < 3) { | |
308 o.attachment = buildDiskAttachment(); | |
309 o.autoDelete = true; | |
310 o.boot = true; | |
311 o.initializeParams = buildNewDiskInitializeParams(); | |
312 } | |
313 buildCounterNewDisk--; | |
314 return o; | |
315 } | |
316 | |
317 checkNewDisk(api.NewDisk o) { | |
318 buildCounterNewDisk++; | |
319 if (buildCounterNewDisk < 3) { | |
320 checkDiskAttachment(o.attachment); | |
321 unittest.expect(o.autoDelete, unittest.isTrue); | |
322 unittest.expect(o.boot, unittest.isTrue); | |
323 checkNewDiskInitializeParams(o.initializeParams); | |
324 } | |
325 buildCounterNewDisk--; | |
326 } | |
327 | |
328 core.int buildCounterNewDiskInitializeParams = 0; | |
329 buildNewDiskInitializeParams() { | |
330 var o = new api.NewDiskInitializeParams(); | |
331 buildCounterNewDiskInitializeParams++; | |
332 if (buildCounterNewDiskInitializeParams < 3) { | |
333 o.diskSizeGb = "foo"; | |
334 o.diskType = "foo"; | |
335 o.sourceImage = "foo"; | |
336 } | |
337 buildCounterNewDiskInitializeParams--; | |
338 return o; | |
339 } | |
340 | |
341 checkNewDiskInitializeParams(api.NewDiskInitializeParams o) { | |
342 buildCounterNewDiskInitializeParams++; | |
343 if (buildCounterNewDiskInitializeParams < 3) { | |
344 unittest.expect(o.diskSizeGb, unittest.equals('foo')); | |
345 unittest.expect(o.diskType, unittest.equals('foo')); | |
346 unittest.expect(o.sourceImage, unittest.equals('foo')); | |
347 } | |
348 buildCounterNewDiskInitializeParams--; | |
349 } | |
350 | |
351 buildUnnamed1063() { | |
352 var o = new core.List<api.HealthCheck>(); | |
353 o.add(buildHealthCheck()); | |
354 o.add(buildHealthCheck()); | |
355 return o; | |
356 } | |
357 | |
358 checkUnnamed1063(core.List<api.HealthCheck> o) { | |
359 unittest.expect(o, unittest.hasLength(2)); | |
360 checkHealthCheck(o[0]); | |
361 checkHealthCheck(o[1]); | |
362 } | |
363 | |
364 buildUnnamed1064() { | |
365 var o = new core.List<api.Label>(); | |
366 o.add(buildLabel()); | |
367 o.add(buildLabel()); | |
368 return o; | |
369 } | |
370 | |
371 checkUnnamed1064(core.List<api.Label> o) { | |
372 unittest.expect(o, unittest.hasLength(2)); | |
373 checkLabel(o[0]); | |
374 checkLabel(o[1]); | |
375 } | |
376 | |
377 buildUnnamed1065() { | |
378 var o = new core.List<core.String>(); | |
379 o.add("foo"); | |
380 o.add("foo"); | |
381 return o; | |
382 } | |
383 | |
384 checkUnnamed1065(core.List<core.String> o) { | |
385 unittest.expect(o, unittest.hasLength(2)); | |
386 unittest.expect(o[0], unittest.equals('foo')); | |
387 unittest.expect(o[1], unittest.equals('foo')); | |
388 } | |
389 | |
390 buildUnnamed1066() { | |
391 var o = new core.List<core.String>(); | |
392 o.add("foo"); | |
393 o.add("foo"); | |
394 return o; | |
395 } | |
396 | |
397 checkUnnamed1066(core.List<core.String> o) { | |
398 unittest.expect(o, unittest.hasLength(2)); | |
399 unittest.expect(o[0], unittest.equals('foo')); | |
400 unittest.expect(o[1], unittest.equals('foo')); | |
401 } | |
402 | |
403 core.int buildCounterPool = 0; | |
404 buildPool() { | |
405 var o = new api.Pool(); | |
406 buildCounterPool++; | |
407 if (buildCounterPool < 3) { | |
408 o.autoRestart = true; | |
409 o.baseInstanceName = "foo"; | |
410 o.currentNumReplicas = 42; | |
411 o.description = "foo"; | |
412 o.healthChecks = buildUnnamed1063(); | |
413 o.initialNumReplicas = 42; | |
414 o.labels = buildUnnamed1064(); | |
415 o.name = "foo"; | |
416 o.numReplicas = 42; | |
417 o.resourceViews = buildUnnamed1065(); | |
418 o.selfLink = "foo"; | |
419 o.targetPool = "foo"; | |
420 o.targetPools = buildUnnamed1066(); | |
421 o.template = buildTemplate(); | |
422 o.type = "foo"; | |
423 } | |
424 buildCounterPool--; | |
425 return o; | |
426 } | |
427 | |
428 checkPool(api.Pool o) { | |
429 buildCounterPool++; | |
430 if (buildCounterPool < 3) { | |
431 unittest.expect(o.autoRestart, unittest.isTrue); | |
432 unittest.expect(o.baseInstanceName, unittest.equals('foo')); | |
433 unittest.expect(o.currentNumReplicas, unittest.equals(42)); | |
434 unittest.expect(o.description, unittest.equals('foo')); | |
435 checkUnnamed1063(o.healthChecks); | |
436 unittest.expect(o.initialNumReplicas, unittest.equals(42)); | |
437 checkUnnamed1064(o.labels); | |
438 unittest.expect(o.name, unittest.equals('foo')); | |
439 unittest.expect(o.numReplicas, unittest.equals(42)); | |
440 checkUnnamed1065(o.resourceViews); | |
441 unittest.expect(o.selfLink, unittest.equals('foo')); | |
442 unittest.expect(o.targetPool, unittest.equals('foo')); | |
443 checkUnnamed1066(o.targetPools); | |
444 checkTemplate(o.template); | |
445 unittest.expect(o.type, unittest.equals('foo')); | |
446 } | |
447 buildCounterPool--; | |
448 } | |
449 | |
450 buildUnnamed1067() { | |
451 var o = new core.List<core.String>(); | |
452 o.add("foo"); | |
453 o.add("foo"); | |
454 return o; | |
455 } | |
456 | |
457 checkUnnamed1067(core.List<core.String> o) { | |
458 unittest.expect(o, unittest.hasLength(2)); | |
459 unittest.expect(o[0], unittest.equals('foo')); | |
460 unittest.expect(o[1], unittest.equals('foo')); | |
461 } | |
462 | |
463 core.int buildCounterPoolsDeleteRequest = 0; | |
464 buildPoolsDeleteRequest() { | |
465 var o = new api.PoolsDeleteRequest(); | |
466 buildCounterPoolsDeleteRequest++; | |
467 if (buildCounterPoolsDeleteRequest < 3) { | |
468 o.abandonInstances = buildUnnamed1067(); | |
469 } | |
470 buildCounterPoolsDeleteRequest--; | |
471 return o; | |
472 } | |
473 | |
474 checkPoolsDeleteRequest(api.PoolsDeleteRequest o) { | |
475 buildCounterPoolsDeleteRequest++; | |
476 if (buildCounterPoolsDeleteRequest < 3) { | |
477 checkUnnamed1067(o.abandonInstances); | |
478 } | |
479 buildCounterPoolsDeleteRequest--; | |
480 } | |
481 | |
482 buildUnnamed1068() { | |
483 var o = new core.List<api.Pool>(); | |
484 o.add(buildPool()); | |
485 o.add(buildPool()); | |
486 return o; | |
487 } | |
488 | |
489 checkUnnamed1068(core.List<api.Pool> o) { | |
490 unittest.expect(o, unittest.hasLength(2)); | |
491 checkPool(o[0]); | |
492 checkPool(o[1]); | |
493 } | |
494 | |
495 core.int buildCounterPoolsListResponse = 0; | |
496 buildPoolsListResponse() { | |
497 var o = new api.PoolsListResponse(); | |
498 buildCounterPoolsListResponse++; | |
499 if (buildCounterPoolsListResponse < 3) { | |
500 o.nextPageToken = "foo"; | |
501 o.resources = buildUnnamed1068(); | |
502 } | |
503 buildCounterPoolsListResponse--; | |
504 return o; | |
505 } | |
506 | |
507 checkPoolsListResponse(api.PoolsListResponse o) { | |
508 buildCounterPoolsListResponse++; | |
509 if (buildCounterPoolsListResponse < 3) { | |
510 unittest.expect(o.nextPageToken, unittest.equals('foo')); | |
511 checkUnnamed1068(o.resources); | |
512 } | |
513 buildCounterPoolsListResponse--; | |
514 } | |
515 | |
516 core.int buildCounterReplica = 0; | |
517 buildReplica() { | |
518 var o = new api.Replica(); | |
519 buildCounterReplica++; | |
520 if (buildCounterReplica < 3) { | |
521 o.name = "foo"; | |
522 o.selfLink = "foo"; | |
523 o.status = buildReplicaStatus(); | |
524 } | |
525 buildCounterReplica--; | |
526 return o; | |
527 } | |
528 | |
529 checkReplica(api.Replica o) { | |
530 buildCounterReplica++; | |
531 if (buildCounterReplica < 3) { | |
532 unittest.expect(o.name, unittest.equals('foo')); | |
533 unittest.expect(o.selfLink, unittest.equals('foo')); | |
534 checkReplicaStatus(o.status); | |
535 } | |
536 buildCounterReplica--; | |
537 } | |
538 | |
539 core.int buildCounterReplicaStatus = 0; | |
540 buildReplicaStatus() { | |
541 var o = new api.ReplicaStatus(); | |
542 buildCounterReplicaStatus++; | |
543 if (buildCounterReplicaStatus < 3) { | |
544 o.details = "foo"; | |
545 o.state = "foo"; | |
546 o.templateVersion = "foo"; | |
547 o.vmLink = "foo"; | |
548 o.vmStartTime = "foo"; | |
549 } | |
550 buildCounterReplicaStatus--; | |
551 return o; | |
552 } | |
553 | |
554 checkReplicaStatus(api.ReplicaStatus o) { | |
555 buildCounterReplicaStatus++; | |
556 if (buildCounterReplicaStatus < 3) { | |
557 unittest.expect(o.details, unittest.equals('foo')); | |
558 unittest.expect(o.state, unittest.equals('foo')); | |
559 unittest.expect(o.templateVersion, unittest.equals('foo')); | |
560 unittest.expect(o.vmLink, unittest.equals('foo')); | |
561 unittest.expect(o.vmStartTime, unittest.equals('foo')); | |
562 } | |
563 buildCounterReplicaStatus--; | |
564 } | |
565 | |
566 core.int buildCounterReplicasDeleteRequest = 0; | |
567 buildReplicasDeleteRequest() { | |
568 var o = new api.ReplicasDeleteRequest(); | |
569 buildCounterReplicasDeleteRequest++; | |
570 if (buildCounterReplicasDeleteRequest < 3) { | |
571 o.abandonInstance = true; | |
572 } | |
573 buildCounterReplicasDeleteRequest--; | |
574 return o; | |
575 } | |
576 | |
577 checkReplicasDeleteRequest(api.ReplicasDeleteRequest o) { | |
578 buildCounterReplicasDeleteRequest++; | |
579 if (buildCounterReplicasDeleteRequest < 3) { | |
580 unittest.expect(o.abandonInstance, unittest.isTrue); | |
581 } | |
582 buildCounterReplicasDeleteRequest--; | |
583 } | |
584 | |
585 buildUnnamed1069() { | |
586 var o = new core.List<api.Replica>(); | |
587 o.add(buildReplica()); | |
588 o.add(buildReplica()); | |
589 return o; | |
590 } | |
591 | |
592 checkUnnamed1069(core.List<api.Replica> o) { | |
593 unittest.expect(o, unittest.hasLength(2)); | |
594 checkReplica(o[0]); | |
595 checkReplica(o[1]); | |
596 } | |
597 | |
598 core.int buildCounterReplicasListResponse = 0; | |
599 buildReplicasListResponse() { | |
600 var o = new api.ReplicasListResponse(); | |
601 buildCounterReplicasListResponse++; | |
602 if (buildCounterReplicasListResponse < 3) { | |
603 o.nextPageToken = "foo"; | |
604 o.resources = buildUnnamed1069(); | |
605 } | |
606 buildCounterReplicasListResponse--; | |
607 return o; | |
608 } | |
609 | |
610 checkReplicasListResponse(api.ReplicasListResponse o) { | |
611 buildCounterReplicasListResponse++; | |
612 if (buildCounterReplicasListResponse < 3) { | |
613 unittest.expect(o.nextPageToken, unittest.equals('foo')); | |
614 checkUnnamed1069(o.resources); | |
615 } | |
616 buildCounterReplicasListResponse--; | |
617 } | |
618 | |
619 buildUnnamed1070() { | |
620 var o = new core.List<core.String>(); | |
621 o.add("foo"); | |
622 o.add("foo"); | |
623 return o; | |
624 } | |
625 | |
626 checkUnnamed1070(core.List<core.String> o) { | |
627 unittest.expect(o, unittest.hasLength(2)); | |
628 unittest.expect(o[0], unittest.equals('foo')); | |
629 unittest.expect(o[1], unittest.equals('foo')); | |
630 } | |
631 | |
632 core.int buildCounterServiceAccount = 0; | |
633 buildServiceAccount() { | |
634 var o = new api.ServiceAccount(); | |
635 buildCounterServiceAccount++; | |
636 if (buildCounterServiceAccount < 3) { | |
637 o.email = "foo"; | |
638 o.scopes = buildUnnamed1070(); | |
639 } | |
640 buildCounterServiceAccount--; | |
641 return o; | |
642 } | |
643 | |
644 checkServiceAccount(api.ServiceAccount o) { | |
645 buildCounterServiceAccount++; | |
646 if (buildCounterServiceAccount < 3) { | |
647 unittest.expect(o.email, unittest.equals('foo')); | |
648 checkUnnamed1070(o.scopes); | |
649 } | |
650 buildCounterServiceAccount--; | |
651 } | |
652 | |
653 buildUnnamed1071() { | |
654 var o = new core.List<core.String>(); | |
655 o.add("foo"); | |
656 o.add("foo"); | |
657 return o; | |
658 } | |
659 | |
660 checkUnnamed1071(core.List<core.String> o) { | |
661 unittest.expect(o, unittest.hasLength(2)); | |
662 unittest.expect(o[0], unittest.equals('foo')); | |
663 unittest.expect(o[1], unittest.equals('foo')); | |
664 } | |
665 | |
666 core.int buildCounterTag = 0; | |
667 buildTag() { | |
668 var o = new api.Tag(); | |
669 buildCounterTag++; | |
670 if (buildCounterTag < 3) { | |
671 o.fingerPrint = "foo"; | |
672 o.items = buildUnnamed1071(); | |
673 } | |
674 buildCounterTag--; | |
675 return o; | |
676 } | |
677 | |
678 checkTag(api.Tag o) { | |
679 buildCounterTag++; | |
680 if (buildCounterTag < 3) { | |
681 unittest.expect(o.fingerPrint, unittest.equals('foo')); | |
682 checkUnnamed1071(o.items); | |
683 } | |
684 buildCounterTag--; | |
685 } | |
686 | |
687 buildUnnamed1072() { | |
688 var o = new core.List<api.HealthCheck>(); | |
689 o.add(buildHealthCheck()); | |
690 o.add(buildHealthCheck()); | |
691 return o; | |
692 } | |
693 | |
694 checkUnnamed1072(core.List<api.HealthCheck> o) { | |
695 unittest.expect(o, unittest.hasLength(2)); | |
696 checkHealthCheck(o[0]); | |
697 checkHealthCheck(o[1]); | |
698 } | |
699 | |
700 core.int buildCounterTemplate = 0; | |
701 buildTemplate() { | |
702 var o = new api.Template(); | |
703 buildCounterTemplate++; | |
704 if (buildCounterTemplate < 3) { | |
705 o.action = buildAction(); | |
706 o.healthChecks = buildUnnamed1072(); | |
707 o.version = "foo"; | |
708 o.vmParams = buildVmParams(); | |
709 } | |
710 buildCounterTemplate--; | |
711 return o; | |
712 } | |
713 | |
714 checkTemplate(api.Template o) { | |
715 buildCounterTemplate++; | |
716 if (buildCounterTemplate < 3) { | |
717 checkAction(o.action); | |
718 checkUnnamed1072(o.healthChecks); | |
719 unittest.expect(o.version, unittest.equals('foo')); | |
720 checkVmParams(o.vmParams); | |
721 } | |
722 buildCounterTemplate--; | |
723 } | |
724 | |
725 buildUnnamed1073() { | |
726 var o = new core.List<api.ExistingDisk>(); | |
727 o.add(buildExistingDisk()); | |
728 o.add(buildExistingDisk()); | |
729 return o; | |
730 } | |
731 | |
732 checkUnnamed1073(core.List<api.ExistingDisk> o) { | |
733 unittest.expect(o, unittest.hasLength(2)); | |
734 checkExistingDisk(o[0]); | |
735 checkExistingDisk(o[1]); | |
736 } | |
737 | |
738 buildUnnamed1074() { | |
739 var o = new core.List<api.NewDisk>(); | |
740 o.add(buildNewDisk()); | |
741 o.add(buildNewDisk()); | |
742 return o; | |
743 } | |
744 | |
745 checkUnnamed1074(core.List<api.NewDisk> o) { | |
746 unittest.expect(o, unittest.hasLength(2)); | |
747 checkNewDisk(o[0]); | |
748 checkNewDisk(o[1]); | |
749 } | |
750 | |
751 buildUnnamed1075() { | |
752 var o = new core.List<api.NetworkInterface>(); | |
753 o.add(buildNetworkInterface()); | |
754 o.add(buildNetworkInterface()); | |
755 return o; | |
756 } | |
757 | |
758 checkUnnamed1075(core.List<api.NetworkInterface> o) { | |
759 unittest.expect(o, unittest.hasLength(2)); | |
760 checkNetworkInterface(o[0]); | |
761 checkNetworkInterface(o[1]); | |
762 } | |
763 | |
764 buildUnnamed1076() { | |
765 var o = new core.List<api.ServiceAccount>(); | |
766 o.add(buildServiceAccount()); | |
767 o.add(buildServiceAccount()); | |
768 return o; | |
769 } | |
770 | |
771 checkUnnamed1076(core.List<api.ServiceAccount> o) { | |
772 unittest.expect(o, unittest.hasLength(2)); | |
773 checkServiceAccount(o[0]); | |
774 checkServiceAccount(o[1]); | |
775 } | |
776 | |
777 core.int buildCounterVmParams = 0; | |
778 buildVmParams() { | |
779 var o = new api.VmParams(); | |
780 buildCounterVmParams++; | |
781 if (buildCounterVmParams < 3) { | |
782 o.baseInstanceName = "foo"; | |
783 o.canIpForward = true; | |
784 o.description = "foo"; | |
785 o.disksToAttach = buildUnnamed1073(); | |
786 o.disksToCreate = buildUnnamed1074(); | |
787 o.machineType = "foo"; | |
788 o.metadata = buildMetadata(); | |
789 o.networkInterfaces = buildUnnamed1075(); | |
790 o.onHostMaintenance = "foo"; | |
791 o.serviceAccounts = buildUnnamed1076(); | |
792 o.tags = buildTag(); | |
793 } | |
794 buildCounterVmParams--; | |
795 return o; | |
796 } | |
797 | |
798 checkVmParams(api.VmParams o) { | |
799 buildCounterVmParams++; | |
800 if (buildCounterVmParams < 3) { | |
801 unittest.expect(o.baseInstanceName, unittest.equals('foo')); | |
802 unittest.expect(o.canIpForward, unittest.isTrue); | |
803 unittest.expect(o.description, unittest.equals('foo')); | |
804 checkUnnamed1073(o.disksToAttach); | |
805 checkUnnamed1074(o.disksToCreate); | |
806 unittest.expect(o.machineType, unittest.equals('foo')); | |
807 checkMetadata(o.metadata); | |
808 checkUnnamed1075(o.networkInterfaces); | |
809 unittest.expect(o.onHostMaintenance, unittest.equals('foo')); | |
810 checkUnnamed1076(o.serviceAccounts); | |
811 checkTag(o.tags); | |
812 } | |
813 buildCounterVmParams--; | |
814 } | |
815 | |
816 | |
817 main() { | |
818 unittest.group("obj-schema-AccessConfig", () { | |
819 unittest.test("to-json--from-json", () { | |
820 var o = buildAccessConfig(); | |
821 var od = new api.AccessConfig.fromJson(o.toJson()); | |
822 checkAccessConfig(od); | |
823 }); | |
824 }); | |
825 | |
826 | |
827 unittest.group("obj-schema-Action", () { | |
828 unittest.test("to-json--from-json", () { | |
829 var o = buildAction(); | |
830 var od = new api.Action.fromJson(o.toJson()); | |
831 checkAction(od); | |
832 }); | |
833 }); | |
834 | |
835 | |
836 unittest.group("obj-schema-DiskAttachment", () { | |
837 unittest.test("to-json--from-json", () { | |
838 var o = buildDiskAttachment(); | |
839 var od = new api.DiskAttachment.fromJson(o.toJson()); | |
840 checkDiskAttachment(od); | |
841 }); | |
842 }); | |
843 | |
844 | |
845 unittest.group("obj-schema-EnvVariable", () { | |
846 unittest.test("to-json--from-json", () { | |
847 var o = buildEnvVariable(); | |
848 var od = new api.EnvVariable.fromJson(o.toJson()); | |
849 checkEnvVariable(od); | |
850 }); | |
851 }); | |
852 | |
853 | |
854 unittest.group("obj-schema-ExistingDisk", () { | |
855 unittest.test("to-json--from-json", () { | |
856 var o = buildExistingDisk(); | |
857 var od = new api.ExistingDisk.fromJson(o.toJson()); | |
858 checkExistingDisk(od); | |
859 }); | |
860 }); | |
861 | |
862 | |
863 unittest.group("obj-schema-HealthCheck", () { | |
864 unittest.test("to-json--from-json", () { | |
865 var o = buildHealthCheck(); | |
866 var od = new api.HealthCheck.fromJson(o.toJson()); | |
867 checkHealthCheck(od); | |
868 }); | |
869 }); | |
870 | |
871 | |
872 unittest.group("obj-schema-Label", () { | |
873 unittest.test("to-json--from-json", () { | |
874 var o = buildLabel(); | |
875 var od = new api.Label.fromJson(o.toJson()); | |
876 checkLabel(od); | |
877 }); | |
878 }); | |
879 | |
880 | |
881 unittest.group("obj-schema-Metadata", () { | |
882 unittest.test("to-json--from-json", () { | |
883 var o = buildMetadata(); | |
884 var od = new api.Metadata.fromJson(o.toJson()); | |
885 checkMetadata(od); | |
886 }); | |
887 }); | |
888 | |
889 | |
890 unittest.group("obj-schema-MetadataItem", () { | |
891 unittest.test("to-json--from-json", () { | |
892 var o = buildMetadataItem(); | |
893 var od = new api.MetadataItem.fromJson(o.toJson()); | |
894 checkMetadataItem(od); | |
895 }); | |
896 }); | |
897 | |
898 | |
899 unittest.group("obj-schema-NetworkInterface", () { | |
900 unittest.test("to-json--from-json", () { | |
901 var o = buildNetworkInterface(); | |
902 var od = new api.NetworkInterface.fromJson(o.toJson()); | |
903 checkNetworkInterface(od); | |
904 }); | |
905 }); | |
906 | |
907 | |
908 unittest.group("obj-schema-NewDisk", () { | |
909 unittest.test("to-json--from-json", () { | |
910 var o = buildNewDisk(); | |
911 var od = new api.NewDisk.fromJson(o.toJson()); | |
912 checkNewDisk(od); | |
913 }); | |
914 }); | |
915 | |
916 | |
917 unittest.group("obj-schema-NewDiskInitializeParams", () { | |
918 unittest.test("to-json--from-json", () { | |
919 var o = buildNewDiskInitializeParams(); | |
920 var od = new api.NewDiskInitializeParams.fromJson(o.toJson()); | |
921 checkNewDiskInitializeParams(od); | |
922 }); | |
923 }); | |
924 | |
925 | |
926 unittest.group("obj-schema-Pool", () { | |
927 unittest.test("to-json--from-json", () { | |
928 var o = buildPool(); | |
929 var od = new api.Pool.fromJson(o.toJson()); | |
930 checkPool(od); | |
931 }); | |
932 }); | |
933 | |
934 | |
935 unittest.group("obj-schema-PoolsDeleteRequest", () { | |
936 unittest.test("to-json--from-json", () { | |
937 var o = buildPoolsDeleteRequest(); | |
938 var od = new api.PoolsDeleteRequest.fromJson(o.toJson()); | |
939 checkPoolsDeleteRequest(od); | |
940 }); | |
941 }); | |
942 | |
943 | |
944 unittest.group("obj-schema-PoolsListResponse", () { | |
945 unittest.test("to-json--from-json", () { | |
946 var o = buildPoolsListResponse(); | |
947 var od = new api.PoolsListResponse.fromJson(o.toJson()); | |
948 checkPoolsListResponse(od); | |
949 }); | |
950 }); | |
951 | |
952 | |
953 unittest.group("obj-schema-Replica", () { | |
954 unittest.test("to-json--from-json", () { | |
955 var o = buildReplica(); | |
956 var od = new api.Replica.fromJson(o.toJson()); | |
957 checkReplica(od); | |
958 }); | |
959 }); | |
960 | |
961 | |
962 unittest.group("obj-schema-ReplicaStatus", () { | |
963 unittest.test("to-json--from-json", () { | |
964 var o = buildReplicaStatus(); | |
965 var od = new api.ReplicaStatus.fromJson(o.toJson()); | |
966 checkReplicaStatus(od); | |
967 }); | |
968 }); | |
969 | |
970 | |
971 unittest.group("obj-schema-ReplicasDeleteRequest", () { | |
972 unittest.test("to-json--from-json", () { | |
973 var o = buildReplicasDeleteRequest(); | |
974 var od = new api.ReplicasDeleteRequest.fromJson(o.toJson()); | |
975 checkReplicasDeleteRequest(od); | |
976 }); | |
977 }); | |
978 | |
979 | |
980 unittest.group("obj-schema-ReplicasListResponse", () { | |
981 unittest.test("to-json--from-json", () { | |
982 var o = buildReplicasListResponse(); | |
983 var od = new api.ReplicasListResponse.fromJson(o.toJson()); | |
984 checkReplicasListResponse(od); | |
985 }); | |
986 }); | |
987 | |
988 | |
989 unittest.group("obj-schema-ServiceAccount", () { | |
990 unittest.test("to-json--from-json", () { | |
991 var o = buildServiceAccount(); | |
992 var od = new api.ServiceAccount.fromJson(o.toJson()); | |
993 checkServiceAccount(od); | |
994 }); | |
995 }); | |
996 | |
997 | |
998 unittest.group("obj-schema-Tag", () { | |
999 unittest.test("to-json--from-json", () { | |
1000 var o = buildTag(); | |
1001 var od = new api.Tag.fromJson(o.toJson()); | |
1002 checkTag(od); | |
1003 }); | |
1004 }); | |
1005 | |
1006 | |
1007 unittest.group("obj-schema-Template", () { | |
1008 unittest.test("to-json--from-json", () { | |
1009 var o = buildTemplate(); | |
1010 var od = new api.Template.fromJson(o.toJson()); | |
1011 checkTemplate(od); | |
1012 }); | |
1013 }); | |
1014 | |
1015 | |
1016 unittest.group("obj-schema-VmParams", () { | |
1017 unittest.test("to-json--from-json", () { | |
1018 var o = buildVmParams(); | |
1019 var od = new api.VmParams.fromJson(o.toJson()); | |
1020 checkVmParams(od); | |
1021 }); | |
1022 }); | |
1023 | |
1024 | |
1025 unittest.group("resource-PoolsResourceApi", () { | |
1026 unittest.test("method--delete", () { | |
1027 | |
1028 var mock = new common_test.HttpServerMock(); | |
1029 api.PoolsResourceApi res = new api.ReplicapoolApi(mock).pools; | |
1030 var arg_request = buildPoolsDeleteRequest(); | |
1031 var arg_projectName = "foo"; | |
1032 var arg_zone = "foo"; | |
1033 var arg_poolName = "foo"; | |
1034 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1035 var obj = new api.PoolsDeleteRequest.fromJson(json); | |
1036 checkPoolsDeleteRequest(obj); | |
1037 | |
1038 var path = (req.url).path; | |
1039 var pathOffset = 0; | |
1040 var index; | |
1041 var subPart; | |
1042 unittest.expect(path.substring(pathOffset, pathOffset + 30), unittest.eq
uals("/replicapool/v1beta1/projects/")); | |
1043 pathOffset += 30; | |
1044 index = path.indexOf("/zones/", pathOffset); | |
1045 unittest.expect(index >= 0, unittest.isTrue); | |
1046 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1047 pathOffset = index; | |
1048 unittest.expect(subPart, unittest.equals("$arg_projectName")); | |
1049 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/zones/")); | |
1050 pathOffset += 7; | |
1051 index = path.indexOf("/pools/", pathOffset); | |
1052 unittest.expect(index >= 0, unittest.isTrue); | |
1053 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1054 pathOffset = index; | |
1055 unittest.expect(subPart, unittest.equals("$arg_zone")); | |
1056 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/pools/")); | |
1057 pathOffset += 7; | |
1058 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | |
1059 pathOffset = path.length; | |
1060 unittest.expect(subPart, unittest.equals("$arg_poolName")); | |
1061 | |
1062 var query = (req.url).query; | |
1063 var queryOffset = 0; | |
1064 var queryMap = {}; | |
1065 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1066 parseBool(n) { | |
1067 if (n == "true") return true; | |
1068 if (n == "false") return false; | |
1069 if (n == null) return null; | |
1070 throw new core.ArgumentError("Invalid boolean: $n"); | |
1071 } | |
1072 if (query.length > 0) { | |
1073 for (var part in query.split("&")) { | |
1074 var keyvalue = part.split("="); | |
1075 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1076 } | |
1077 } | |
1078 | |
1079 | |
1080 var h = { | |
1081 "content-type" : "application/json; charset=utf-8", | |
1082 }; | |
1083 var resp = ""; | |
1084 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1085 }), true); | |
1086 res.delete(arg_request, arg_projectName, arg_zone, arg_poolName).then(unit
test.expectAsync((_) {})); | |
1087 }); | |
1088 | |
1089 unittest.test("method--get", () { | |
1090 | |
1091 var mock = new common_test.HttpServerMock(); | |
1092 api.PoolsResourceApi res = new api.ReplicapoolApi(mock).pools; | |
1093 var arg_projectName = "foo"; | |
1094 var arg_zone = "foo"; | |
1095 var arg_poolName = "foo"; | |
1096 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1097 var path = (req.url).path; | |
1098 var pathOffset = 0; | |
1099 var index; | |
1100 var subPart; | |
1101 unittest.expect(path.substring(pathOffset, pathOffset + 30), unittest.eq
uals("/replicapool/v1beta1/projects/")); | |
1102 pathOffset += 30; | |
1103 index = path.indexOf("/zones/", pathOffset); | |
1104 unittest.expect(index >= 0, unittest.isTrue); | |
1105 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1106 pathOffset = index; | |
1107 unittest.expect(subPart, unittest.equals("$arg_projectName")); | |
1108 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/zones/")); | |
1109 pathOffset += 7; | |
1110 index = path.indexOf("/pools/", pathOffset); | |
1111 unittest.expect(index >= 0, unittest.isTrue); | |
1112 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1113 pathOffset = index; | |
1114 unittest.expect(subPart, unittest.equals("$arg_zone")); | |
1115 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/pools/")); | |
1116 pathOffset += 7; | |
1117 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | |
1118 pathOffset = path.length; | |
1119 unittest.expect(subPart, unittest.equals("$arg_poolName")); | |
1120 | |
1121 var query = (req.url).query; | |
1122 var queryOffset = 0; | |
1123 var queryMap = {}; | |
1124 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1125 parseBool(n) { | |
1126 if (n == "true") return true; | |
1127 if (n == "false") return false; | |
1128 if (n == null) return null; | |
1129 throw new core.ArgumentError("Invalid boolean: $n"); | |
1130 } | |
1131 if (query.length > 0) { | |
1132 for (var part in query.split("&")) { | |
1133 var keyvalue = part.split("="); | |
1134 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1135 } | |
1136 } | |
1137 | |
1138 | |
1139 var h = { | |
1140 "content-type" : "application/json; charset=utf-8", | |
1141 }; | |
1142 var resp = convert.JSON.encode(buildPool()); | |
1143 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1144 }), true); | |
1145 res.get(arg_projectName, arg_zone, arg_poolName).then(unittest.expectAsync
(((api.Pool response) { | |
1146 checkPool(response); | |
1147 }))); | |
1148 }); | |
1149 | |
1150 unittest.test("method--insert", () { | |
1151 | |
1152 var mock = new common_test.HttpServerMock(); | |
1153 api.PoolsResourceApi res = new api.ReplicapoolApi(mock).pools; | |
1154 var arg_request = buildPool(); | |
1155 var arg_projectName = "foo"; | |
1156 var arg_zone = "foo"; | |
1157 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1158 var obj = new api.Pool.fromJson(json); | |
1159 checkPool(obj); | |
1160 | |
1161 var path = (req.url).path; | |
1162 var pathOffset = 0; | |
1163 var index; | |
1164 var subPart; | |
1165 unittest.expect(path.substring(pathOffset, pathOffset + 30), unittest.eq
uals("/replicapool/v1beta1/projects/")); | |
1166 pathOffset += 30; | |
1167 index = path.indexOf("/zones/", pathOffset); | |
1168 unittest.expect(index >= 0, unittest.isTrue); | |
1169 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1170 pathOffset = index; | |
1171 unittest.expect(subPart, unittest.equals("$arg_projectName")); | |
1172 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/zones/")); | |
1173 pathOffset += 7; | |
1174 index = path.indexOf("/pools", pathOffset); | |
1175 unittest.expect(index >= 0, unittest.isTrue); | |
1176 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1177 pathOffset = index; | |
1178 unittest.expect(subPart, unittest.equals("$arg_zone")); | |
1179 unittest.expect(path.substring(pathOffset, pathOffset + 6), unittest.equ
als("/pools")); | |
1180 pathOffset += 6; | |
1181 | |
1182 var query = (req.url).query; | |
1183 var queryOffset = 0; | |
1184 var queryMap = {}; | |
1185 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1186 parseBool(n) { | |
1187 if (n == "true") return true; | |
1188 if (n == "false") return false; | |
1189 if (n == null) return null; | |
1190 throw new core.ArgumentError("Invalid boolean: $n"); | |
1191 } | |
1192 if (query.length > 0) { | |
1193 for (var part in query.split("&")) { | |
1194 var keyvalue = part.split("="); | |
1195 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1196 } | |
1197 } | |
1198 | |
1199 | |
1200 var h = { | |
1201 "content-type" : "application/json; charset=utf-8", | |
1202 }; | |
1203 var resp = convert.JSON.encode(buildPool()); | |
1204 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1205 }), true); | |
1206 res.insert(arg_request, arg_projectName, arg_zone).then(unittest.expectAsy
nc(((api.Pool response) { | |
1207 checkPool(response); | |
1208 }))); | |
1209 }); | |
1210 | |
1211 unittest.test("method--list", () { | |
1212 | |
1213 var mock = new common_test.HttpServerMock(); | |
1214 api.PoolsResourceApi res = new api.ReplicapoolApi(mock).pools; | |
1215 var arg_projectName = "foo"; | |
1216 var arg_zone = "foo"; | |
1217 var arg_maxResults = 42; | |
1218 var arg_pageToken = "foo"; | |
1219 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1220 var path = (req.url).path; | |
1221 var pathOffset = 0; | |
1222 var index; | |
1223 var subPart; | |
1224 unittest.expect(path.substring(pathOffset, pathOffset + 30), unittest.eq
uals("/replicapool/v1beta1/projects/")); | |
1225 pathOffset += 30; | |
1226 index = path.indexOf("/zones/", pathOffset); | |
1227 unittest.expect(index >= 0, unittest.isTrue); | |
1228 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1229 pathOffset = index; | |
1230 unittest.expect(subPart, unittest.equals("$arg_projectName")); | |
1231 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/zones/")); | |
1232 pathOffset += 7; | |
1233 index = path.indexOf("/pools", pathOffset); | |
1234 unittest.expect(index >= 0, unittest.isTrue); | |
1235 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1236 pathOffset = index; | |
1237 unittest.expect(subPart, unittest.equals("$arg_zone")); | |
1238 unittest.expect(path.substring(pathOffset, pathOffset + 6), unittest.equ
als("/pools")); | |
1239 pathOffset += 6; | |
1240 | |
1241 var query = (req.url).query; | |
1242 var queryOffset = 0; | |
1243 var queryMap = {}; | |
1244 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1245 parseBool(n) { | |
1246 if (n == "true") return true; | |
1247 if (n == "false") return false; | |
1248 if (n == null) return null; | |
1249 throw new core.ArgumentError("Invalid boolean: $n"); | |
1250 } | |
1251 if (query.length > 0) { | |
1252 for (var part in query.split("&")) { | |
1253 var keyvalue = part.split("="); | |
1254 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1255 } | |
1256 } | |
1257 unittest.expect(core.int.parse(queryMap["maxResults"].first), unittest.e
quals(arg_maxResults)); | |
1258 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | |
1259 | |
1260 | |
1261 var h = { | |
1262 "content-type" : "application/json; charset=utf-8", | |
1263 }; | |
1264 var resp = convert.JSON.encode(buildPoolsListResponse()); | |
1265 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1266 }), true); | |
1267 res.list(arg_projectName, arg_zone, maxResults: arg_maxResults, pageToken:
arg_pageToken).then(unittest.expectAsync(((api.PoolsListResponse response) { | |
1268 checkPoolsListResponse(response); | |
1269 }))); | |
1270 }); | |
1271 | |
1272 unittest.test("method--resize", () { | |
1273 | |
1274 var mock = new common_test.HttpServerMock(); | |
1275 api.PoolsResourceApi res = new api.ReplicapoolApi(mock).pools; | |
1276 var arg_projectName = "foo"; | |
1277 var arg_zone = "foo"; | |
1278 var arg_poolName = "foo"; | |
1279 var arg_numReplicas = 42; | |
1280 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1281 var path = (req.url).path; | |
1282 var pathOffset = 0; | |
1283 var index; | |
1284 var subPart; | |
1285 unittest.expect(path.substring(pathOffset, pathOffset + 30), unittest.eq
uals("/replicapool/v1beta1/projects/")); | |
1286 pathOffset += 30; | |
1287 index = path.indexOf("/zones/", pathOffset); | |
1288 unittest.expect(index >= 0, unittest.isTrue); | |
1289 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1290 pathOffset = index; | |
1291 unittest.expect(subPart, unittest.equals("$arg_projectName")); | |
1292 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/zones/")); | |
1293 pathOffset += 7; | |
1294 index = path.indexOf("/pools/", pathOffset); | |
1295 unittest.expect(index >= 0, unittest.isTrue); | |
1296 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1297 pathOffset = index; | |
1298 unittest.expect(subPart, unittest.equals("$arg_zone")); | |
1299 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/pools/")); | |
1300 pathOffset += 7; | |
1301 index = path.indexOf("/resize", pathOffset); | |
1302 unittest.expect(index >= 0, unittest.isTrue); | |
1303 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1304 pathOffset = index; | |
1305 unittest.expect(subPart, unittest.equals("$arg_poolName")); | |
1306 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/resize")); | |
1307 pathOffset += 7; | |
1308 | |
1309 var query = (req.url).query; | |
1310 var queryOffset = 0; | |
1311 var queryMap = {}; | |
1312 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1313 parseBool(n) { | |
1314 if (n == "true") return true; | |
1315 if (n == "false") return false; | |
1316 if (n == null) return null; | |
1317 throw new core.ArgumentError("Invalid boolean: $n"); | |
1318 } | |
1319 if (query.length > 0) { | |
1320 for (var part in query.split("&")) { | |
1321 var keyvalue = part.split("="); | |
1322 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1323 } | |
1324 } | |
1325 unittest.expect(core.int.parse(queryMap["numReplicas"].first), unittest.
equals(arg_numReplicas)); | |
1326 | |
1327 | |
1328 var h = { | |
1329 "content-type" : "application/json; charset=utf-8", | |
1330 }; | |
1331 var resp = convert.JSON.encode(buildPool()); | |
1332 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1333 }), true); | |
1334 res.resize(arg_projectName, arg_zone, arg_poolName, numReplicas: arg_numRe
plicas).then(unittest.expectAsync(((api.Pool response) { | |
1335 checkPool(response); | |
1336 }))); | |
1337 }); | |
1338 | |
1339 unittest.test("method--updatetemplate", () { | |
1340 | |
1341 var mock = new common_test.HttpServerMock(); | |
1342 api.PoolsResourceApi res = new api.ReplicapoolApi(mock).pools; | |
1343 var arg_request = buildTemplate(); | |
1344 var arg_projectName = "foo"; | |
1345 var arg_zone = "foo"; | |
1346 var arg_poolName = "foo"; | |
1347 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1348 var obj = new api.Template.fromJson(json); | |
1349 checkTemplate(obj); | |
1350 | |
1351 var path = (req.url).path; | |
1352 var pathOffset = 0; | |
1353 var index; | |
1354 var subPart; | |
1355 unittest.expect(path.substring(pathOffset, pathOffset + 30), unittest.eq
uals("/replicapool/v1beta1/projects/")); | |
1356 pathOffset += 30; | |
1357 index = path.indexOf("/zones/", pathOffset); | |
1358 unittest.expect(index >= 0, unittest.isTrue); | |
1359 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1360 pathOffset = index; | |
1361 unittest.expect(subPart, unittest.equals("$arg_projectName")); | |
1362 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/zones/")); | |
1363 pathOffset += 7; | |
1364 index = path.indexOf("/pools/", pathOffset); | |
1365 unittest.expect(index >= 0, unittest.isTrue); | |
1366 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1367 pathOffset = index; | |
1368 unittest.expect(subPart, unittest.equals("$arg_zone")); | |
1369 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/pools/")); | |
1370 pathOffset += 7; | |
1371 index = path.indexOf("/updateTemplate", pathOffset); | |
1372 unittest.expect(index >= 0, unittest.isTrue); | |
1373 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1374 pathOffset = index; | |
1375 unittest.expect(subPart, unittest.equals("$arg_poolName")); | |
1376 unittest.expect(path.substring(pathOffset, pathOffset + 15), unittest.eq
uals("/updateTemplate")); | |
1377 pathOffset += 15; | |
1378 | |
1379 var query = (req.url).query; | |
1380 var queryOffset = 0; | |
1381 var queryMap = {}; | |
1382 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1383 parseBool(n) { | |
1384 if (n == "true") return true; | |
1385 if (n == "false") return false; | |
1386 if (n == null) return null; | |
1387 throw new core.ArgumentError("Invalid boolean: $n"); | |
1388 } | |
1389 if (query.length > 0) { | |
1390 for (var part in query.split("&")) { | |
1391 var keyvalue = part.split("="); | |
1392 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1393 } | |
1394 } | |
1395 | |
1396 | |
1397 var h = { | |
1398 "content-type" : "application/json; charset=utf-8", | |
1399 }; | |
1400 var resp = ""; | |
1401 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1402 }), true); | |
1403 res.updatetemplate(arg_request, arg_projectName, arg_zone, arg_poolName).t
hen(unittest.expectAsync((_) {})); | |
1404 }); | |
1405 | |
1406 }); | |
1407 | |
1408 | |
1409 unittest.group("resource-ReplicasResourceApi", () { | |
1410 unittest.test("method--delete", () { | |
1411 | |
1412 var mock = new common_test.HttpServerMock(); | |
1413 api.ReplicasResourceApi res = new api.ReplicapoolApi(mock).replicas; | |
1414 var arg_request = buildReplicasDeleteRequest(); | |
1415 var arg_projectName = "foo"; | |
1416 var arg_zone = "foo"; | |
1417 var arg_poolName = "foo"; | |
1418 var arg_replicaName = "foo"; | |
1419 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1420 var obj = new api.ReplicasDeleteRequest.fromJson(json); | |
1421 checkReplicasDeleteRequest(obj); | |
1422 | |
1423 var path = (req.url).path; | |
1424 var pathOffset = 0; | |
1425 var index; | |
1426 var subPart; | |
1427 unittest.expect(path.substring(pathOffset, pathOffset + 30), unittest.eq
uals("/replicapool/v1beta1/projects/")); | |
1428 pathOffset += 30; | |
1429 index = path.indexOf("/zones/", pathOffset); | |
1430 unittest.expect(index >= 0, unittest.isTrue); | |
1431 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1432 pathOffset = index; | |
1433 unittest.expect(subPart, unittest.equals("$arg_projectName")); | |
1434 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/zones/")); | |
1435 pathOffset += 7; | |
1436 index = path.indexOf("/pools/", pathOffset); | |
1437 unittest.expect(index >= 0, unittest.isTrue); | |
1438 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1439 pathOffset = index; | |
1440 unittest.expect(subPart, unittest.equals("$arg_zone")); | |
1441 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/pools/")); | |
1442 pathOffset += 7; | |
1443 index = path.indexOf("/replicas/", pathOffset); | |
1444 unittest.expect(index >= 0, unittest.isTrue); | |
1445 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1446 pathOffset = index; | |
1447 unittest.expect(subPart, unittest.equals("$arg_poolName")); | |
1448 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("/replicas/")); | |
1449 pathOffset += 10; | |
1450 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | |
1451 pathOffset = path.length; | |
1452 unittest.expect(subPart, unittest.equals("$arg_replicaName")); | |
1453 | |
1454 var query = (req.url).query; | |
1455 var queryOffset = 0; | |
1456 var queryMap = {}; | |
1457 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1458 parseBool(n) { | |
1459 if (n == "true") return true; | |
1460 if (n == "false") return false; | |
1461 if (n == null) return null; | |
1462 throw new core.ArgumentError("Invalid boolean: $n"); | |
1463 } | |
1464 if (query.length > 0) { | |
1465 for (var part in query.split("&")) { | |
1466 var keyvalue = part.split("="); | |
1467 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1468 } | |
1469 } | |
1470 | |
1471 | |
1472 var h = { | |
1473 "content-type" : "application/json; charset=utf-8", | |
1474 }; | |
1475 var resp = convert.JSON.encode(buildReplica()); | |
1476 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1477 }), true); | |
1478 res.delete(arg_request, arg_projectName, arg_zone, arg_poolName, arg_repli
caName).then(unittest.expectAsync(((api.Replica response) { | |
1479 checkReplica(response); | |
1480 }))); | |
1481 }); | |
1482 | |
1483 unittest.test("method--get", () { | |
1484 | |
1485 var mock = new common_test.HttpServerMock(); | |
1486 api.ReplicasResourceApi res = new api.ReplicapoolApi(mock).replicas; | |
1487 var arg_projectName = "foo"; | |
1488 var arg_zone = "foo"; | |
1489 var arg_poolName = "foo"; | |
1490 var arg_replicaName = "foo"; | |
1491 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1492 var path = (req.url).path; | |
1493 var pathOffset = 0; | |
1494 var index; | |
1495 var subPart; | |
1496 unittest.expect(path.substring(pathOffset, pathOffset + 30), unittest.eq
uals("/replicapool/v1beta1/projects/")); | |
1497 pathOffset += 30; | |
1498 index = path.indexOf("/zones/", pathOffset); | |
1499 unittest.expect(index >= 0, unittest.isTrue); | |
1500 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1501 pathOffset = index; | |
1502 unittest.expect(subPart, unittest.equals("$arg_projectName")); | |
1503 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/zones/")); | |
1504 pathOffset += 7; | |
1505 index = path.indexOf("/pools/", pathOffset); | |
1506 unittest.expect(index >= 0, unittest.isTrue); | |
1507 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1508 pathOffset = index; | |
1509 unittest.expect(subPart, unittest.equals("$arg_zone")); | |
1510 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/pools/")); | |
1511 pathOffset += 7; | |
1512 index = path.indexOf("/replicas/", pathOffset); | |
1513 unittest.expect(index >= 0, unittest.isTrue); | |
1514 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1515 pathOffset = index; | |
1516 unittest.expect(subPart, unittest.equals("$arg_poolName")); | |
1517 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("/replicas/")); | |
1518 pathOffset += 10; | |
1519 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset)); | |
1520 pathOffset = path.length; | |
1521 unittest.expect(subPart, unittest.equals("$arg_replicaName")); | |
1522 | |
1523 var query = (req.url).query; | |
1524 var queryOffset = 0; | |
1525 var queryMap = {}; | |
1526 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1527 parseBool(n) { | |
1528 if (n == "true") return true; | |
1529 if (n == "false") return false; | |
1530 if (n == null) return null; | |
1531 throw new core.ArgumentError("Invalid boolean: $n"); | |
1532 } | |
1533 if (query.length > 0) { | |
1534 for (var part in query.split("&")) { | |
1535 var keyvalue = part.split("="); | |
1536 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1537 } | |
1538 } | |
1539 | |
1540 | |
1541 var h = { | |
1542 "content-type" : "application/json; charset=utf-8", | |
1543 }; | |
1544 var resp = convert.JSON.encode(buildReplica()); | |
1545 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1546 }), true); | |
1547 res.get(arg_projectName, arg_zone, arg_poolName, arg_replicaName).then(uni
ttest.expectAsync(((api.Replica response) { | |
1548 checkReplica(response); | |
1549 }))); | |
1550 }); | |
1551 | |
1552 unittest.test("method--list", () { | |
1553 | |
1554 var mock = new common_test.HttpServerMock(); | |
1555 api.ReplicasResourceApi res = new api.ReplicapoolApi(mock).replicas; | |
1556 var arg_projectName = "foo"; | |
1557 var arg_zone = "foo"; | |
1558 var arg_poolName = "foo"; | |
1559 var arg_maxResults = 42; | |
1560 var arg_pageToken = "foo"; | |
1561 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1562 var path = (req.url).path; | |
1563 var pathOffset = 0; | |
1564 var index; | |
1565 var subPart; | |
1566 unittest.expect(path.substring(pathOffset, pathOffset + 30), unittest.eq
uals("/replicapool/v1beta1/projects/")); | |
1567 pathOffset += 30; | |
1568 index = path.indexOf("/zones/", pathOffset); | |
1569 unittest.expect(index >= 0, unittest.isTrue); | |
1570 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1571 pathOffset = index; | |
1572 unittest.expect(subPart, unittest.equals("$arg_projectName")); | |
1573 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/zones/")); | |
1574 pathOffset += 7; | |
1575 index = path.indexOf("/pools/", pathOffset); | |
1576 unittest.expect(index >= 0, unittest.isTrue); | |
1577 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1578 pathOffset = index; | |
1579 unittest.expect(subPart, unittest.equals("$arg_zone")); | |
1580 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/pools/")); | |
1581 pathOffset += 7; | |
1582 index = path.indexOf("/replicas", pathOffset); | |
1583 unittest.expect(index >= 0, unittest.isTrue); | |
1584 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1585 pathOffset = index; | |
1586 unittest.expect(subPart, unittest.equals("$arg_poolName")); | |
1587 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("/replicas")); | |
1588 pathOffset += 9; | |
1589 | |
1590 var query = (req.url).query; | |
1591 var queryOffset = 0; | |
1592 var queryMap = {}; | |
1593 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1594 parseBool(n) { | |
1595 if (n == "true") return true; | |
1596 if (n == "false") return false; | |
1597 if (n == null) return null; | |
1598 throw new core.ArgumentError("Invalid boolean: $n"); | |
1599 } | |
1600 if (query.length > 0) { | |
1601 for (var part in query.split("&")) { | |
1602 var keyvalue = part.split("="); | |
1603 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1604 } | |
1605 } | |
1606 unittest.expect(core.int.parse(queryMap["maxResults"].first), unittest.e
quals(arg_maxResults)); | |
1607 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | |
1608 | |
1609 | |
1610 var h = { | |
1611 "content-type" : "application/json; charset=utf-8", | |
1612 }; | |
1613 var resp = convert.JSON.encode(buildReplicasListResponse()); | |
1614 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1615 }), true); | |
1616 res.list(arg_projectName, arg_zone, arg_poolName, maxResults: arg_maxResul
ts, pageToken: arg_pageToken).then(unittest.expectAsync(((api.ReplicasListRespon
se response) { | |
1617 checkReplicasListResponse(response); | |
1618 }))); | |
1619 }); | |
1620 | |
1621 unittest.test("method--restart", () { | |
1622 | |
1623 var mock = new common_test.HttpServerMock(); | |
1624 api.ReplicasResourceApi res = new api.ReplicapoolApi(mock).replicas; | |
1625 var arg_projectName = "foo"; | |
1626 var arg_zone = "foo"; | |
1627 var arg_poolName = "foo"; | |
1628 var arg_replicaName = "foo"; | |
1629 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
1630 var path = (req.url).path; | |
1631 var pathOffset = 0; | |
1632 var index; | |
1633 var subPart; | |
1634 unittest.expect(path.substring(pathOffset, pathOffset + 30), unittest.eq
uals("/replicapool/v1beta1/projects/")); | |
1635 pathOffset += 30; | |
1636 index = path.indexOf("/zones/", pathOffset); | |
1637 unittest.expect(index >= 0, unittest.isTrue); | |
1638 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1639 pathOffset = index; | |
1640 unittest.expect(subPart, unittest.equals("$arg_projectName")); | |
1641 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/zones/")); | |
1642 pathOffset += 7; | |
1643 index = path.indexOf("/pools/", pathOffset); | |
1644 unittest.expect(index >= 0, unittest.isTrue); | |
1645 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1646 pathOffset = index; | |
1647 unittest.expect(subPart, unittest.equals("$arg_zone")); | |
1648 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ
als("/pools/")); | |
1649 pathOffset += 7; | |
1650 index = path.indexOf("/replicas/", pathOffset); | |
1651 unittest.expect(index >= 0, unittest.isTrue); | |
1652 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1653 pathOffset = index; | |
1654 unittest.expect(subPart, unittest.equals("$arg_poolName")); | |
1655 unittest.expect(path.substring(pathOffset, pathOffset + 10), unittest.eq
uals("/replicas/")); | |
1656 pathOffset += 10; | |
1657 index = path.indexOf("/restart", pathOffset); | |
1658 unittest.expect(index >= 0, unittest.isTrue); | |
1659 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index
)); | |
1660 pathOffset = index; | |
1661 unittest.expect(subPart, unittest.equals("$arg_replicaName")); | |
1662 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ
als("/restart")); | |
1663 pathOffset += 8; | |
1664 | |
1665 var query = (req.url).query; | |
1666 var queryOffset = 0; | |
1667 var queryMap = {}; | |
1668 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
1669 parseBool(n) { | |
1670 if (n == "true") return true; | |
1671 if (n == "false") return false; | |
1672 if (n == null) return null; | |
1673 throw new core.ArgumentError("Invalid boolean: $n"); | |
1674 } | |
1675 if (query.length > 0) { | |
1676 for (var part in query.split("&")) { | |
1677 var keyvalue = part.split("="); | |
1678 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
1679 } | |
1680 } | |
1681 | |
1682 | |
1683 var h = { | |
1684 "content-type" : "application/json; charset=utf-8", | |
1685 }; | |
1686 var resp = convert.JSON.encode(buildReplica()); | |
1687 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
1688 }), true); | |
1689 res.restart(arg_projectName, arg_zone, arg_poolName, arg_replicaName).then
(unittest.expectAsync(((api.Replica response) { | |
1690 checkReplica(response); | |
1691 }))); | |
1692 }); | |
1693 | |
1694 }); | |
1695 | |
1696 | |
1697 } | |
1698 | |
OLD | NEW |