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

Side by Side Diff: generated/googleapis/test/cloudbuild/v1_test.dart

Issue 2159673002: Api-roll 39: 2016-07-18 (Closed) Base URL: git@github.com:dart-lang/googleapis.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 library googleapis.cloudbuild.v1.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
12 import 'package:googleapis/cloudbuild/v1.dart' as api;
13
14 class HttpServerMock extends http.BaseClient {
15 core.Function _callback;
16 core.bool _expectJson;
17
18 void register(core.Function callback, core.bool expectJson) {
19 _callback = callback;
20 _expectJson = expectJson;
21 }
22
23 async.Future<http.StreamedResponse> send(http.BaseRequest request) {
24 if (_expectJson) {
25 return request.finalize()
26 .transform(convert.UTF8.decoder)
27 .join('')
28 .then((core.String jsonString) {
29 if (jsonString.isEmpty) {
30 return _callback(request, null);
31 } else {
32 return _callback(request, convert.JSON.decode(jsonString));
33 }
34 });
35 } else {
36 var stream = request.finalize();
37 if (stream == null) {
38 return _callback(request, []);
39 } else {
40 return stream.toBytes().then((data) {
41 return _callback(request, data);
42 });
43 }
44 }
45 }
46 }
47
48 http.StreamedResponse stringResponse(
49 core.int status, core.Map headers, core.String body) {
50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]);
51 return new http.StreamedResponse(stream, status, headers: headers);
52 }
53
54 buildUnnamed1286() {
55 var o = new core.List<core.String>();
56 o.add("foo");
57 o.add("foo");
58 return o;
59 }
60
61 checkUnnamed1286(core.List<core.String> o) {
62 unittest.expect(o, unittest.hasLength(2));
63 unittest.expect(o[0], unittest.equals('foo'));
64 unittest.expect(o[1], unittest.equals('foo'));
65 }
66
67 buildUnnamed1287() {
68 var o = new core.List<api.BuildStep>();
69 o.add(buildBuildStep());
70 o.add(buildBuildStep());
71 return o;
72 }
73
74 checkUnnamed1287(core.List<api.BuildStep> o) {
75 unittest.expect(o, unittest.hasLength(2));
76 checkBuildStep(o[0]);
77 checkBuildStep(o[1]);
78 }
79
80 core.int buildCounterBuild = 0;
81 buildBuild() {
82 var o = new api.Build();
83 buildCounterBuild++;
84 if (buildCounterBuild < 3) {
85 o.createTime = "foo";
86 o.finishTime = "foo";
87 o.id = "foo";
88 o.images = buildUnnamed1286();
89 o.logsBucket = "foo";
90 o.options = buildBuildOptions();
91 o.projectId = "foo";
92 o.results = buildResults();
93 o.source = buildSource();
94 o.sourceProvenance = buildSourceProvenance();
95 o.startTime = "foo";
96 o.status = "foo";
97 o.statusDetail = "foo";
98 o.steps = buildUnnamed1287();
99 o.timeout = "foo";
100 }
101 buildCounterBuild--;
102 return o;
103 }
104
105 checkBuild(api.Build o) {
106 buildCounterBuild++;
107 if (buildCounterBuild < 3) {
108 unittest.expect(o.createTime, unittest.equals('foo'));
109 unittest.expect(o.finishTime, unittest.equals('foo'));
110 unittest.expect(o.id, unittest.equals('foo'));
111 checkUnnamed1286(o.images);
112 unittest.expect(o.logsBucket, unittest.equals('foo'));
113 checkBuildOptions(o.options);
114 unittest.expect(o.projectId, unittest.equals('foo'));
115 checkResults(o.results);
116 checkSource(o.source);
117 checkSourceProvenance(o.sourceProvenance);
118 unittest.expect(o.startTime, unittest.equals('foo'));
119 unittest.expect(o.status, unittest.equals('foo'));
120 unittest.expect(o.statusDetail, unittest.equals('foo'));
121 checkUnnamed1287(o.steps);
122 unittest.expect(o.timeout, unittest.equals('foo'));
123 }
124 buildCounterBuild--;
125 }
126
127 core.int buildCounterBuildOperationMetadata = 0;
128 buildBuildOperationMetadata() {
129 var o = new api.BuildOperationMetadata();
130 buildCounterBuildOperationMetadata++;
131 if (buildCounterBuildOperationMetadata < 3) {
132 o.build = buildBuild();
133 }
134 buildCounterBuildOperationMetadata--;
135 return o;
136 }
137
138 checkBuildOperationMetadata(api.BuildOperationMetadata o) {
139 buildCounterBuildOperationMetadata++;
140 if (buildCounterBuildOperationMetadata < 3) {
141 checkBuild(o.build);
142 }
143 buildCounterBuildOperationMetadata--;
144 }
145
146 buildUnnamed1288() {
147 var o = new core.List<core.String>();
148 o.add("foo");
149 o.add("foo");
150 return o;
151 }
152
153 checkUnnamed1288(core.List<core.String> o) {
154 unittest.expect(o, unittest.hasLength(2));
155 unittest.expect(o[0], unittest.equals('foo'));
156 unittest.expect(o[1], unittest.equals('foo'));
157 }
158
159 core.int buildCounterBuildOptions = 0;
160 buildBuildOptions() {
161 var o = new api.BuildOptions();
162 buildCounterBuildOptions++;
163 if (buildCounterBuildOptions < 3) {
164 o.requestedVerifyOption = "foo";
165 o.sourceProvenanceHash = buildUnnamed1288();
166 }
167 buildCounterBuildOptions--;
168 return o;
169 }
170
171 checkBuildOptions(api.BuildOptions o) {
172 buildCounterBuildOptions++;
173 if (buildCounterBuildOptions < 3) {
174 unittest.expect(o.requestedVerifyOption, unittest.equals('foo'));
175 checkUnnamed1288(o.sourceProvenanceHash);
176 }
177 buildCounterBuildOptions--;
178 }
179
180 buildUnnamed1289() {
181 var o = new core.List<core.String>();
182 o.add("foo");
183 o.add("foo");
184 return o;
185 }
186
187 checkUnnamed1289(core.List<core.String> o) {
188 unittest.expect(o, unittest.hasLength(2));
189 unittest.expect(o[0], unittest.equals('foo'));
190 unittest.expect(o[1], unittest.equals('foo'));
191 }
192
193 buildUnnamed1290() {
194 var o = new core.List<core.String>();
195 o.add("foo");
196 o.add("foo");
197 return o;
198 }
199
200 checkUnnamed1290(core.List<core.String> o) {
201 unittest.expect(o, unittest.hasLength(2));
202 unittest.expect(o[0], unittest.equals('foo'));
203 unittest.expect(o[1], unittest.equals('foo'));
204 }
205
206 core.int buildCounterBuildStep = 0;
207 buildBuildStep() {
208 var o = new api.BuildStep();
209 buildCounterBuildStep++;
210 if (buildCounterBuildStep < 3) {
211 o.args = buildUnnamed1289();
212 o.dir = "foo";
213 o.env = buildUnnamed1290();
214 o.name = "foo";
215 }
216 buildCounterBuildStep--;
217 return o;
218 }
219
220 checkBuildStep(api.BuildStep o) {
221 buildCounterBuildStep++;
222 if (buildCounterBuildStep < 3) {
223 checkUnnamed1289(o.args);
224 unittest.expect(o.dir, unittest.equals('foo'));
225 checkUnnamed1290(o.env);
226 unittest.expect(o.name, unittest.equals('foo'));
227 }
228 buildCounterBuildStep--;
229 }
230
231 core.int buildCounterBuiltImage = 0;
232 buildBuiltImage() {
233 var o = new api.BuiltImage();
234 buildCounterBuiltImage++;
235 if (buildCounterBuiltImage < 3) {
236 o.digest = "foo";
237 o.name = "foo";
238 }
239 buildCounterBuiltImage--;
240 return o;
241 }
242
243 checkBuiltImage(api.BuiltImage o) {
244 buildCounterBuiltImage++;
245 if (buildCounterBuiltImage < 3) {
246 unittest.expect(o.digest, unittest.equals('foo'));
247 unittest.expect(o.name, unittest.equals('foo'));
248 }
249 buildCounterBuiltImage--;
250 }
251
252 core.int buildCounterCancelBuildRequest = 0;
253 buildCancelBuildRequest() {
254 var o = new api.CancelBuildRequest();
255 buildCounterCancelBuildRequest++;
256 if (buildCounterCancelBuildRequest < 3) {
257 }
258 buildCounterCancelBuildRequest--;
259 return o;
260 }
261
262 checkCancelBuildRequest(api.CancelBuildRequest o) {
263 buildCounterCancelBuildRequest++;
264 if (buildCounterCancelBuildRequest < 3) {
265 }
266 buildCounterCancelBuildRequest--;
267 }
268
269 buildUnnamed1291() {
270 var o = new core.List<api.Hash>();
271 o.add(buildHash());
272 o.add(buildHash());
273 return o;
274 }
275
276 checkUnnamed1291(core.List<api.Hash> o) {
277 unittest.expect(o, unittest.hasLength(2));
278 checkHash(o[0]);
279 checkHash(o[1]);
280 }
281
282 core.int buildCounterFileHashes = 0;
283 buildFileHashes() {
284 var o = new api.FileHashes();
285 buildCounterFileHashes++;
286 if (buildCounterFileHashes < 3) {
287 o.fileHash = buildUnnamed1291();
288 }
289 buildCounterFileHashes--;
290 return o;
291 }
292
293 checkFileHashes(api.FileHashes o) {
294 buildCounterFileHashes++;
295 if (buildCounterFileHashes < 3) {
296 checkUnnamed1291(o.fileHash);
297 }
298 buildCounterFileHashes--;
299 }
300
301 core.int buildCounterHash = 0;
302 buildHash() {
303 var o = new api.Hash();
304 buildCounterHash++;
305 if (buildCounterHash < 3) {
306 o.type = "foo";
307 o.value = "foo";
308 }
309 buildCounterHash--;
310 return o;
311 }
312
313 checkHash(api.Hash o) {
314 buildCounterHash++;
315 if (buildCounterHash < 3) {
316 unittest.expect(o.type, unittest.equals('foo'));
317 unittest.expect(o.value, unittest.equals('foo'));
318 }
319 buildCounterHash--;
320 }
321
322 buildUnnamed1292() {
323 var o = new core.List<api.Build>();
324 o.add(buildBuild());
325 o.add(buildBuild());
326 return o;
327 }
328
329 checkUnnamed1292(core.List<api.Build> o) {
330 unittest.expect(o, unittest.hasLength(2));
331 checkBuild(o[0]);
332 checkBuild(o[1]);
333 }
334
335 core.int buildCounterListBuildsResponse = 0;
336 buildListBuildsResponse() {
337 var o = new api.ListBuildsResponse();
338 buildCounterListBuildsResponse++;
339 if (buildCounterListBuildsResponse < 3) {
340 o.builds = buildUnnamed1292();
341 o.nextPageToken = "foo";
342 }
343 buildCounterListBuildsResponse--;
344 return o;
345 }
346
347 checkListBuildsResponse(api.ListBuildsResponse o) {
348 buildCounterListBuildsResponse++;
349 if (buildCounterListBuildsResponse < 3) {
350 checkUnnamed1292(o.builds);
351 unittest.expect(o.nextPageToken, unittest.equals('foo'));
352 }
353 buildCounterListBuildsResponse--;
354 }
355
356 buildUnnamed1293() {
357 var o = new core.List<api.Operation>();
358 o.add(buildOperation());
359 o.add(buildOperation());
360 return o;
361 }
362
363 checkUnnamed1293(core.List<api.Operation> o) {
364 unittest.expect(o, unittest.hasLength(2));
365 checkOperation(o[0]);
366 checkOperation(o[1]);
367 }
368
369 core.int buildCounterListOperationsResponse = 0;
370 buildListOperationsResponse() {
371 var o = new api.ListOperationsResponse();
372 buildCounterListOperationsResponse++;
373 if (buildCounterListOperationsResponse < 3) {
374 o.nextPageToken = "foo";
375 o.operations = buildUnnamed1293();
376 }
377 buildCounterListOperationsResponse--;
378 return o;
379 }
380
381 checkListOperationsResponse(api.ListOperationsResponse o) {
382 buildCounterListOperationsResponse++;
383 if (buildCounterListOperationsResponse < 3) {
384 unittest.expect(o.nextPageToken, unittest.equals('foo'));
385 checkUnnamed1293(o.operations);
386 }
387 buildCounterListOperationsResponse--;
388 }
389
390 buildUnnamed1294() {
391 var o = new core.Map<core.String, core.Object>();
392 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
393 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
394 return o;
395 }
396
397 checkUnnamed1294(core.Map<core.String, core.Object> o) {
398 unittest.expect(o, unittest.hasLength(2));
399 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'));
400 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'));
401 }
402
403 buildUnnamed1295() {
404 var o = new core.Map<core.String, core.Object>();
405 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
406 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
407 return o;
408 }
409
410 checkUnnamed1295(core.Map<core.String, core.Object> o) {
411 unittest.expect(o, unittest.hasLength(2));
412 var casted3 = (o["x"]) as core.Map; unittest.expect(casted3, unittest.hasLengt h(3)); unittest.expect(casted3["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted3["bool"], unittest.equals(true)); unittest.expect(casted3["string"], unittest.equals('foo'));
413 var casted4 = (o["y"]) as core.Map; unittest.expect(casted4, unittest.hasLengt h(3)); unittest.expect(casted4["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted4["bool"], unittest.equals(true)); unittest.expect(casted4["string"], unittest.equals('foo'));
414 }
415
416 core.int buildCounterOperation = 0;
417 buildOperation() {
418 var o = new api.Operation();
419 buildCounterOperation++;
420 if (buildCounterOperation < 3) {
421 o.done = true;
422 o.error = buildStatus();
423 o.metadata = buildUnnamed1294();
424 o.name = "foo";
425 o.response = buildUnnamed1295();
426 }
427 buildCounterOperation--;
428 return o;
429 }
430
431 checkOperation(api.Operation o) {
432 buildCounterOperation++;
433 if (buildCounterOperation < 3) {
434 unittest.expect(o.done, unittest.isTrue);
435 checkStatus(o.error);
436 checkUnnamed1294(o.metadata);
437 unittest.expect(o.name, unittest.equals('foo'));
438 checkUnnamed1295(o.response);
439 }
440 buildCounterOperation--;
441 }
442
443 buildUnnamed1296() {
444 var o = new core.List<api.BuiltImage>();
445 o.add(buildBuiltImage());
446 o.add(buildBuiltImage());
447 return o;
448 }
449
450 checkUnnamed1296(core.List<api.BuiltImage> o) {
451 unittest.expect(o, unittest.hasLength(2));
452 checkBuiltImage(o[0]);
453 checkBuiltImage(o[1]);
454 }
455
456 core.int buildCounterResults = 0;
457 buildResults() {
458 var o = new api.Results();
459 buildCounterResults++;
460 if (buildCounterResults < 3) {
461 o.images = buildUnnamed1296();
462 }
463 buildCounterResults--;
464 return o;
465 }
466
467 checkResults(api.Results o) {
468 buildCounterResults++;
469 if (buildCounterResults < 3) {
470 checkUnnamed1296(o.images);
471 }
472 buildCounterResults--;
473 }
474
475 core.int buildCounterSource = 0;
476 buildSource() {
477 var o = new api.Source();
478 buildCounterSource++;
479 if (buildCounterSource < 3) {
480 o.storageSource = buildStorageSource();
481 }
482 buildCounterSource--;
483 return o;
484 }
485
486 checkSource(api.Source o) {
487 buildCounterSource++;
488 if (buildCounterSource < 3) {
489 checkStorageSource(o.storageSource);
490 }
491 buildCounterSource--;
492 }
493
494 buildUnnamed1297() {
495 var o = new core.Map<core.String, api.FileHashes>();
496 o["x"] = buildFileHashes();
497 o["y"] = buildFileHashes();
498 return o;
499 }
500
501 checkUnnamed1297(core.Map<core.String, api.FileHashes> o) {
502 unittest.expect(o, unittest.hasLength(2));
503 checkFileHashes(o["x"]);
504 checkFileHashes(o["y"]);
505 }
506
507 core.int buildCounterSourceProvenance = 0;
508 buildSourceProvenance() {
509 var o = new api.SourceProvenance();
510 buildCounterSourceProvenance++;
511 if (buildCounterSourceProvenance < 3) {
512 o.fileHashes = buildUnnamed1297();
513 }
514 buildCounterSourceProvenance--;
515 return o;
516 }
517
518 checkSourceProvenance(api.SourceProvenance o) {
519 buildCounterSourceProvenance++;
520 if (buildCounterSourceProvenance < 3) {
521 checkUnnamed1297(o.fileHashes);
522 }
523 buildCounterSourceProvenance--;
524 }
525
526 buildUnnamed1298() {
527 var o = new core.Map<core.String, core.Object>();
528 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
529 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
530 return o;
531 }
532
533 checkUnnamed1298(core.Map<core.String, core.Object> o) {
534 unittest.expect(o, unittest.hasLength(2));
535 var casted5 = (o["x"]) as core.Map; unittest.expect(casted5, unittest.hasLengt h(3)); unittest.expect(casted5["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted5["bool"], unittest.equals(true)); unittest.expect(casted5["string"], unittest.equals('foo'));
536 var casted6 = (o["y"]) as core.Map; unittest.expect(casted6, unittest.hasLengt h(3)); unittest.expect(casted6["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted6["bool"], unittest.equals(true)); unittest.expect(casted6["string"], unittest.equals('foo'));
537 }
538
539 buildUnnamed1299() {
540 var o = new core.List<core.Map<core.String, core.Object>>();
541 o.add(buildUnnamed1298());
542 o.add(buildUnnamed1298());
543 return o;
544 }
545
546 checkUnnamed1299(core.List<core.Map<core.String, core.Object>> o) {
547 unittest.expect(o, unittest.hasLength(2));
548 checkUnnamed1298(o[0]);
549 checkUnnamed1298(o[1]);
550 }
551
552 core.int buildCounterStatus = 0;
553 buildStatus() {
554 var o = new api.Status();
555 buildCounterStatus++;
556 if (buildCounterStatus < 3) {
557 o.code = 42;
558 o.details = buildUnnamed1299();
559 o.message = "foo";
560 }
561 buildCounterStatus--;
562 return o;
563 }
564
565 checkStatus(api.Status o) {
566 buildCounterStatus++;
567 if (buildCounterStatus < 3) {
568 unittest.expect(o.code, unittest.equals(42));
569 checkUnnamed1299(o.details);
570 unittest.expect(o.message, unittest.equals('foo'));
571 }
572 buildCounterStatus--;
573 }
574
575 core.int buildCounterStorageSource = 0;
576 buildStorageSource() {
577 var o = new api.StorageSource();
578 buildCounterStorageSource++;
579 if (buildCounterStorageSource < 3) {
580 o.bucket = "foo";
581 o.generation = "foo";
582 o.object = "foo";
583 }
584 buildCounterStorageSource--;
585 return o;
586 }
587
588 checkStorageSource(api.StorageSource o) {
589 buildCounterStorageSource++;
590 if (buildCounterStorageSource < 3) {
591 unittest.expect(o.bucket, unittest.equals('foo'));
592 unittest.expect(o.generation, unittest.equals('foo'));
593 unittest.expect(o.object, unittest.equals('foo'));
594 }
595 buildCounterStorageSource--;
596 }
597
598
599 main() {
600 unittest.group("obj-schema-Build", () {
601 unittest.test("to-json--from-json", () {
602 var o = buildBuild();
603 var od = new api.Build.fromJson(o.toJson());
604 checkBuild(od);
605 });
606 });
607
608
609 unittest.group("obj-schema-BuildOperationMetadata", () {
610 unittest.test("to-json--from-json", () {
611 var o = buildBuildOperationMetadata();
612 var od = new api.BuildOperationMetadata.fromJson(o.toJson());
613 checkBuildOperationMetadata(od);
614 });
615 });
616
617
618 unittest.group("obj-schema-BuildOptions", () {
619 unittest.test("to-json--from-json", () {
620 var o = buildBuildOptions();
621 var od = new api.BuildOptions.fromJson(o.toJson());
622 checkBuildOptions(od);
623 });
624 });
625
626
627 unittest.group("obj-schema-BuildStep", () {
628 unittest.test("to-json--from-json", () {
629 var o = buildBuildStep();
630 var od = new api.BuildStep.fromJson(o.toJson());
631 checkBuildStep(od);
632 });
633 });
634
635
636 unittest.group("obj-schema-BuiltImage", () {
637 unittest.test("to-json--from-json", () {
638 var o = buildBuiltImage();
639 var od = new api.BuiltImage.fromJson(o.toJson());
640 checkBuiltImage(od);
641 });
642 });
643
644
645 unittest.group("obj-schema-CancelBuildRequest", () {
646 unittest.test("to-json--from-json", () {
647 var o = buildCancelBuildRequest();
648 var od = new api.CancelBuildRequest.fromJson(o.toJson());
649 checkCancelBuildRequest(od);
650 });
651 });
652
653
654 unittest.group("obj-schema-FileHashes", () {
655 unittest.test("to-json--from-json", () {
656 var o = buildFileHashes();
657 var od = new api.FileHashes.fromJson(o.toJson());
658 checkFileHashes(od);
659 });
660 });
661
662
663 unittest.group("obj-schema-Hash", () {
664 unittest.test("to-json--from-json", () {
665 var o = buildHash();
666 var od = new api.Hash.fromJson(o.toJson());
667 checkHash(od);
668 });
669 });
670
671
672 unittest.group("obj-schema-ListBuildsResponse", () {
673 unittest.test("to-json--from-json", () {
674 var o = buildListBuildsResponse();
675 var od = new api.ListBuildsResponse.fromJson(o.toJson());
676 checkListBuildsResponse(od);
677 });
678 });
679
680
681 unittest.group("obj-schema-ListOperationsResponse", () {
682 unittest.test("to-json--from-json", () {
683 var o = buildListOperationsResponse();
684 var od = new api.ListOperationsResponse.fromJson(o.toJson());
685 checkListOperationsResponse(od);
686 });
687 });
688
689
690 unittest.group("obj-schema-Operation", () {
691 unittest.test("to-json--from-json", () {
692 var o = buildOperation();
693 var od = new api.Operation.fromJson(o.toJson());
694 checkOperation(od);
695 });
696 });
697
698
699 unittest.group("obj-schema-Results", () {
700 unittest.test("to-json--from-json", () {
701 var o = buildResults();
702 var od = new api.Results.fromJson(o.toJson());
703 checkResults(od);
704 });
705 });
706
707
708 unittest.group("obj-schema-Source", () {
709 unittest.test("to-json--from-json", () {
710 var o = buildSource();
711 var od = new api.Source.fromJson(o.toJson());
712 checkSource(od);
713 });
714 });
715
716
717 unittest.group("obj-schema-SourceProvenance", () {
718 unittest.test("to-json--from-json", () {
719 var o = buildSourceProvenance();
720 var od = new api.SourceProvenance.fromJson(o.toJson());
721 checkSourceProvenance(od);
722 });
723 });
724
725
726 unittest.group("obj-schema-Status", () {
727 unittest.test("to-json--from-json", () {
728 var o = buildStatus();
729 var od = new api.Status.fromJson(o.toJson());
730 checkStatus(od);
731 });
732 });
733
734
735 unittest.group("obj-schema-StorageSource", () {
736 unittest.test("to-json--from-json", () {
737 var o = buildStorageSource();
738 var od = new api.StorageSource.fromJson(o.toJson());
739 checkStorageSource(od);
740 });
741 });
742
743
744 unittest.group("resource-OperationsResourceApi", () {
745 unittest.test("method--get", () {
746
747 var mock = new HttpServerMock();
748 api.OperationsResourceApi res = new api.CloudbuildApi(mock).operations;
749 var arg_name = "foo";
750 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
751 var path = (req.url).path;
752 var pathOffset = 0;
753 var index;
754 var subPart;
755 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
756 pathOffset += 1;
757 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ als("v1/"));
758 pathOffset += 3;
759 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation;
760
761 var query = (req.url).query;
762 var queryOffset = 0;
763 var queryMap = {};
764 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
765 parseBool(n) {
766 if (n == "true") return true;
767 if (n == "false") return false;
768 if (n == null) return null;
769 throw new core.ArgumentError("Invalid boolean: $n");
770 }
771 if (query.length > 0) {
772 for (var part in query.split("&")) {
773 var keyvalue = part.split("=");
774 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
775 }
776 }
777
778
779 var h = {
780 "content-type" : "application/json; charset=utf-8",
781 };
782 var resp = convert.JSON.encode(buildOperation());
783 return new async.Future.value(stringResponse(200, h, resp));
784 }), true);
785 res.get(arg_name).then(unittest.expectAsync(((api.Operation response) {
786 checkOperation(response);
787 })));
788 });
789
790 unittest.test("method--list", () {
791
792 var mock = new HttpServerMock();
793 api.OperationsResourceApi res = new api.CloudbuildApi(mock).operations;
794 var arg_name = "foo";
795 var arg_pageSize = 42;
796 var arg_filter = "foo";
797 var arg_pageToken = "foo";
798 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
799 var path = (req.url).path;
800 var pathOffset = 0;
801 var index;
802 var subPart;
803 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
804 pathOffset += 1;
805 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ als("v1/"));
806 pathOffset += 3;
807 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation;
808
809 var query = (req.url).query;
810 var queryOffset = 0;
811 var queryMap = {};
812 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
813 parseBool(n) {
814 if (n == "true") return true;
815 if (n == "false") return false;
816 if (n == null) return null;
817 throw new core.ArgumentError("Invalid boolean: $n");
818 }
819 if (query.length > 0) {
820 for (var part in query.split("&")) {
821 var keyvalue = part.split("=");
822 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
823 }
824 }
825 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ als(arg_pageSize));
826 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter));
827 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok en));
828
829
830 var h = {
831 "content-type" : "application/json; charset=utf-8",
832 };
833 var resp = convert.JSON.encode(buildListOperationsResponse());
834 return new async.Future.value(stringResponse(200, h, resp));
835 }), true);
836 res.list(arg_name, pageSize: arg_pageSize, filter: arg_filter, pageToken: arg_pageToken).then(unittest.expectAsync(((api.ListOperationsResponse response) {
837 checkListOperationsResponse(response);
838 })));
839 });
840
841 });
842
843
844 unittest.group("resource-ProjectsBuildsResourceApi", () {
845 unittest.test("method--cancel", () {
846
847 var mock = new HttpServerMock();
848 api.ProjectsBuildsResourceApi res = new api.CloudbuildApi(mock).projects.b uilds;
849 var arg_request = buildCancelBuildRequest();
850 var arg_projectId = "foo";
851 var arg_id = "foo";
852 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
853 var obj = new api.CancelBuildRequest.fromJson(json);
854 checkCancelBuildRequest(obj);
855
856 var path = (req.url).path;
857 var pathOffset = 0;
858 var index;
859 var subPart;
860 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
861 pathOffset += 1;
862 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq uals("v1/projects/"));
863 pathOffset += 12;
864 index = path.indexOf("/builds/", pathOffset);
865 unittest.expect(index >= 0, unittest.isTrue);
866 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
867 pathOffset = index;
868 unittest.expect(subPart, unittest.equals("$arg_projectId"));
869 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ als("/builds/"));
870 pathOffset += 8;
871 index = path.indexOf(":cancel", pathOffset);
872 unittest.expect(index >= 0, unittest.isTrue);
873 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
874 pathOffset = index;
875 unittest.expect(subPart, unittest.equals("$arg_id"));
876 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als(":cancel"));
877 pathOffset += 7;
878
879 var query = (req.url).query;
880 var queryOffset = 0;
881 var queryMap = {};
882 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
883 parseBool(n) {
884 if (n == "true") return true;
885 if (n == "false") return false;
886 if (n == null) return null;
887 throw new core.ArgumentError("Invalid boolean: $n");
888 }
889 if (query.length > 0) {
890 for (var part in query.split("&")) {
891 var keyvalue = part.split("=");
892 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
893 }
894 }
895
896
897 var h = {
898 "content-type" : "application/json; charset=utf-8",
899 };
900 var resp = convert.JSON.encode(buildBuild());
901 return new async.Future.value(stringResponse(200, h, resp));
902 }), true);
903 res.cancel(arg_request, arg_projectId, arg_id).then(unittest.expectAsync(( (api.Build response) {
904 checkBuild(response);
905 })));
906 });
907
908 unittest.test("method--create", () {
909
910 var mock = new HttpServerMock();
911 api.ProjectsBuildsResourceApi res = new api.CloudbuildApi(mock).projects.b uilds;
912 var arg_request = buildBuild();
913 var arg_projectId = "foo";
914 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
915 var obj = new api.Build.fromJson(json);
916 checkBuild(obj);
917
918 var path = (req.url).path;
919 var pathOffset = 0;
920 var index;
921 var subPart;
922 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
923 pathOffset += 1;
924 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq uals("v1/projects/"));
925 pathOffset += 12;
926 index = path.indexOf("/builds", pathOffset);
927 unittest.expect(index >= 0, unittest.isTrue);
928 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
929 pathOffset = index;
930 unittest.expect(subPart, unittest.equals("$arg_projectId"));
931 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/builds"));
932 pathOffset += 7;
933
934 var query = (req.url).query;
935 var queryOffset = 0;
936 var queryMap = {};
937 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
938 parseBool(n) {
939 if (n == "true") return true;
940 if (n == "false") return false;
941 if (n == null) return null;
942 throw new core.ArgumentError("Invalid boolean: $n");
943 }
944 if (query.length > 0) {
945 for (var part in query.split("&")) {
946 var keyvalue = part.split("=");
947 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
948 }
949 }
950
951
952 var h = {
953 "content-type" : "application/json; charset=utf-8",
954 };
955 var resp = convert.JSON.encode(buildOperation());
956 return new async.Future.value(stringResponse(200, h, resp));
957 }), true);
958 res.create(arg_request, arg_projectId).then(unittest.expectAsync(((api.Ope ration response) {
959 checkOperation(response);
960 })));
961 });
962
963 unittest.test("method--get", () {
964
965 var mock = new HttpServerMock();
966 api.ProjectsBuildsResourceApi res = new api.CloudbuildApi(mock).projects.b uilds;
967 var arg_projectId = "foo";
968 var arg_id = "foo";
969 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
970 var path = (req.url).path;
971 var pathOffset = 0;
972 var index;
973 var subPart;
974 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
975 pathOffset += 1;
976 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq uals("v1/projects/"));
977 pathOffset += 12;
978 index = path.indexOf("/builds/", pathOffset);
979 unittest.expect(index >= 0, unittest.isTrue);
980 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
981 pathOffset = index;
982 unittest.expect(subPart, unittest.equals("$arg_projectId"));
983 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ als("/builds/"));
984 pathOffset += 8;
985 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset));
986 pathOffset = path.length;
987 unittest.expect(subPart, unittest.equals("$arg_id"));
988
989 var query = (req.url).query;
990 var queryOffset = 0;
991 var queryMap = {};
992 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
993 parseBool(n) {
994 if (n == "true") return true;
995 if (n == "false") return false;
996 if (n == null) return null;
997 throw new core.ArgumentError("Invalid boolean: $n");
998 }
999 if (query.length > 0) {
1000 for (var part in query.split("&")) {
1001 var keyvalue = part.split("=");
1002 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
1003 }
1004 }
1005
1006
1007 var h = {
1008 "content-type" : "application/json; charset=utf-8",
1009 };
1010 var resp = convert.JSON.encode(buildBuild());
1011 return new async.Future.value(stringResponse(200, h, resp));
1012 }), true);
1013 res.get(arg_projectId, arg_id).then(unittest.expectAsync(((api.Build respo nse) {
1014 checkBuild(response);
1015 })));
1016 });
1017
1018 unittest.test("method--list", () {
1019
1020 var mock = new HttpServerMock();
1021 api.ProjectsBuildsResourceApi res = new api.CloudbuildApi(mock).projects.b uilds;
1022 var arg_projectId = "foo";
1023 var arg_pageSize = 42;
1024 var arg_pageToken = "foo";
1025 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
1026 var path = (req.url).path;
1027 var pathOffset = 0;
1028 var index;
1029 var subPart;
1030 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
1031 pathOffset += 1;
1032 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq uals("v1/projects/"));
1033 pathOffset += 12;
1034 index = path.indexOf("/builds", pathOffset);
1035 unittest.expect(index >= 0, unittest.isTrue);
1036 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
1037 pathOffset = index;
1038 unittest.expect(subPart, unittest.equals("$arg_projectId"));
1039 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("/builds"));
1040 pathOffset += 7;
1041
1042 var query = (req.url).query;
1043 var queryOffset = 0;
1044 var queryMap = {};
1045 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
1046 parseBool(n) {
1047 if (n == "true") return true;
1048 if (n == "false") return false;
1049 if (n == null) return null;
1050 throw new core.ArgumentError("Invalid boolean: $n");
1051 }
1052 if (query.length > 0) {
1053 for (var part in query.split("&")) {
1054 var keyvalue = part.split("=");
1055 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
1056 }
1057 }
1058 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ als(arg_pageSize));
1059 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok en));
1060
1061
1062 var h = {
1063 "content-type" : "application/json; charset=utf-8",
1064 };
1065 var resp = convert.JSON.encode(buildListBuildsResponse());
1066 return new async.Future.value(stringResponse(200, h, resp));
1067 }), true);
1068 res.list(arg_projectId, pageSize: arg_pageSize, pageToken: arg_pageToken). then(unittest.expectAsync(((api.ListBuildsResponse response) {
1069 checkListBuildsResponse(response);
1070 })));
1071 });
1072
1073 });
1074
1075
1076 }
1077
OLDNEW
« no previous file with comments | « generated/googleapis/test/cloudbilling/v1_test.dart ('k') | generated/googleapis/test/clouddebugger/v2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698