| // ignore_for_file: camel_case_types |
| // ignore_for_file: cascade_invocations |
| // ignore_for_file: comment_references |
| // ignore_for_file: file_names |
| // ignore_for_file: library_names |
| // ignore_for_file: lines_longer_than_80_chars |
| // ignore_for_file: non_constant_identifier_names |
| // ignore_for_file: prefer_const_declarations |
| // ignore_for_file: prefer_expression_function_bodies |
| // ignore_for_file: prefer_final_locals |
| // ignore_for_file: prefer_interpolation_to_compose_strings |
| // ignore_for_file: unnecessary_brace_in_string_interps |
| // ignore_for_file: unnecessary_cast |
| // ignore_for_file: unnecessary_lambdas |
| // ignore_for_file: unnecessary_parenthesis |
| // ignore_for_file: unnecessary_string_interpolations |
| // ignore_for_file: unused_local_variable |
| |
| import 'dart:async' as async; |
| import 'dart:convert' as convert; |
| import 'dart:core' as core; |
| |
| import 'package:googleapis_beta/firebasestorage/v1beta.dart' as api; |
| import 'package:http/http.dart' as http; |
| import 'package:test/test.dart' as unittest; |
| |
| import '../test_shared.dart'; |
| |
| core.int buildCounterAddFirebaseRequest = 0; |
| api.AddFirebaseRequest buildAddFirebaseRequest() { |
| final o = api.AddFirebaseRequest(); |
| buildCounterAddFirebaseRequest++; |
| if (buildCounterAddFirebaseRequest < 3) {} |
| buildCounterAddFirebaseRequest--; |
| return o; |
| } |
| |
| void checkAddFirebaseRequest(api.AddFirebaseRequest o) { |
| buildCounterAddFirebaseRequest++; |
| if (buildCounterAddFirebaseRequest < 3) {} |
| buildCounterAddFirebaseRequest--; |
| } |
| |
| core.int buildCounterBucket = 0; |
| api.Bucket buildBucket() { |
| final o = api.Bucket(); |
| buildCounterBucket++; |
| if (buildCounterBucket < 3) { |
| o.location = 'foo'; |
| o.name = 'foo'; |
| o.reconciling = true; |
| } |
| buildCounterBucket--; |
| return o; |
| } |
| |
| void checkBucket(api.Bucket o) { |
| buildCounterBucket++; |
| if (buildCounterBucket < 3) { |
| unittest.expect( |
| o.location!, |
| unittest.equals('foo'), |
| ); |
| unittest.expect( |
| o.name!, |
| unittest.equals('foo'), |
| ); |
| unittest.expect(o.reconciling!, unittest.isTrue); |
| } |
| buildCounterBucket--; |
| } |
| |
| core.int buildCounterEmpty = 0; |
| api.Empty buildEmpty() { |
| final o = api.Empty(); |
| buildCounterEmpty++; |
| if (buildCounterEmpty < 3) {} |
| buildCounterEmpty--; |
| return o; |
| } |
| |
| void checkEmpty(api.Empty o) { |
| buildCounterEmpty++; |
| if (buildCounterEmpty < 3) {} |
| buildCounterEmpty--; |
| } |
| |
| core.int |
| buildCounterGoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata = |
| 0; |
| api.GoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata |
| buildGoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata() { |
| final o = api |
| .GoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata(); |
| buildCounterGoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata++; |
| if (buildCounterGoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata < |
| 3) { |
| o.createTime = 'foo'; |
| o.lastUpdateTime = 'foo'; |
| o.state = 'foo'; |
| } |
| buildCounterGoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata--; |
| return o; |
| } |
| |
| void checkGoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata( |
| api.GoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata |
| o) { |
| buildCounterGoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata++; |
| if (buildCounterGoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata < |
| 3) { |
| unittest.expect( |
| o.createTime!, |
| unittest.equals('foo'), |
| ); |
| unittest.expect( |
| o.lastUpdateTime!, |
| unittest.equals('foo'), |
| ); |
| unittest.expect( |
| o.state!, |
| unittest.equals('foo'), |
| ); |
| } |
| buildCounterGoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata--; |
| } |
| |
| core.int |
| buildCounterGoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata = |
| 0; |
| api.GoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata |
| buildGoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata() { |
| final o = api |
| .GoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata(); |
| buildCounterGoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata++; |
| if (buildCounterGoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata < |
| 3) { |
| o.createTime = 'foo'; |
| o.lastUpdateTime = 'foo'; |
| o.state = 'foo'; |
| } |
| buildCounterGoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata--; |
| return o; |
| } |
| |
| void checkGoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata( |
| api.GoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata |
| o) { |
| buildCounterGoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata++; |
| if (buildCounterGoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata < |
| 3) { |
| unittest.expect( |
| o.createTime!, |
| unittest.equals('foo'), |
| ); |
| unittest.expect( |
| o.lastUpdateTime!, |
| unittest.equals('foo'), |
| ); |
| unittest.expect( |
| o.state!, |
| unittest.equals('foo'), |
| ); |
| } |
| buildCounterGoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata--; |
| } |
| |
| core.List<api.Bucket> buildUnnamed9045() => [ |
| buildBucket(), |
| buildBucket(), |
| ]; |
| |
| void checkUnnamed9045(core.List<api.Bucket> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkBucket(o[0]); |
| checkBucket(o[1]); |
| } |
| |
| core.int buildCounterListBucketsResponse = 0; |
| api.ListBucketsResponse buildListBucketsResponse() { |
| final o = api.ListBucketsResponse(); |
| buildCounterListBucketsResponse++; |
| if (buildCounterListBucketsResponse < 3) { |
| o.buckets = buildUnnamed9045(); |
| o.nextPageToken = 'foo'; |
| } |
| buildCounterListBucketsResponse--; |
| return o; |
| } |
| |
| void checkListBucketsResponse(api.ListBucketsResponse o) { |
| buildCounterListBucketsResponse++; |
| if (buildCounterListBucketsResponse < 3) { |
| checkUnnamed9045(o.buckets!); |
| unittest.expect( |
| o.nextPageToken!, |
| unittest.equals('foo'), |
| ); |
| } |
| buildCounterListBucketsResponse--; |
| } |
| |
| core.int buildCounterRemoveFirebaseRequest = 0; |
| api.RemoveFirebaseRequest buildRemoveFirebaseRequest() { |
| final o = api.RemoveFirebaseRequest(); |
| buildCounterRemoveFirebaseRequest++; |
| if (buildCounterRemoveFirebaseRequest < 3) {} |
| buildCounterRemoveFirebaseRequest--; |
| return o; |
| } |
| |
| void checkRemoveFirebaseRequest(api.RemoveFirebaseRequest o) { |
| buildCounterRemoveFirebaseRequest++; |
| if (buildCounterRemoveFirebaseRequest < 3) {} |
| buildCounterRemoveFirebaseRequest--; |
| } |
| |
| void main() { |
| unittest.group('obj-schema-AddFirebaseRequest', () { |
| unittest.test('to-json--from-json', () async { |
| final o = buildAddFirebaseRequest(); |
| final oJson = convert.jsonDecode(convert.jsonEncode(o)); |
| final od = api.AddFirebaseRequest.fromJson( |
| oJson as core.Map<core.String, core.dynamic>); |
| checkAddFirebaseRequest(od); |
| }); |
| }); |
| |
| unittest.group('obj-schema-Bucket', () { |
| unittest.test('to-json--from-json', () async { |
| final o = buildBucket(); |
| final oJson = convert.jsonDecode(convert.jsonEncode(o)); |
| final od = |
| api.Bucket.fromJson(oJson as core.Map<core.String, core.dynamic>); |
| checkBucket(od); |
| }); |
| }); |
| |
| unittest.group('obj-schema-Empty', () { |
| unittest.test('to-json--from-json', () async { |
| final o = buildEmpty(); |
| final oJson = convert.jsonDecode(convert.jsonEncode(o)); |
| final od = |
| api.Empty.fromJson(oJson as core.Map<core.String, core.dynamic>); |
| checkEmpty(od); |
| }); |
| }); |
| |
| unittest.group( |
| 'obj-schema-GoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata', |
| () { |
| unittest.test('to-json--from-json', () async { |
| final o = |
| buildGoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata(); |
| final oJson = convert.jsonDecode(convert.jsonEncode(o)); |
| final od = |
| api.GoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata |
| .fromJson(oJson as core.Map<core.String, core.dynamic>); |
| checkGoogleFirebaseStorageControlplaneV1alphaMigrateLocationDestructivelyMetadata( |
| od); |
| }); |
| }); |
| |
| unittest.group( |
| 'obj-schema-GoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata', |
| () { |
| unittest.test('to-json--from-json', () async { |
| final o = |
| buildGoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata(); |
| final oJson = convert.jsonDecode(convert.jsonEncode(o)); |
| final od = |
| api.GoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata |
| .fromJson(oJson as core.Map<core.String, core.dynamic>); |
| checkGoogleFirebaseStorageControlplaneV1betaMigrateLocationDestructivelyMetadata( |
| od); |
| }); |
| }); |
| |
| unittest.group('obj-schema-ListBucketsResponse', () { |
| unittest.test('to-json--from-json', () async { |
| final o = buildListBucketsResponse(); |
| final oJson = convert.jsonDecode(convert.jsonEncode(o)); |
| final od = api.ListBucketsResponse.fromJson( |
| oJson as core.Map<core.String, core.dynamic>); |
| checkListBucketsResponse(od); |
| }); |
| }); |
| |
| unittest.group('obj-schema-RemoveFirebaseRequest', () { |
| unittest.test('to-json--from-json', () async { |
| final o = buildRemoveFirebaseRequest(); |
| final oJson = convert.jsonDecode(convert.jsonEncode(o)); |
| final od = api.RemoveFirebaseRequest.fromJson( |
| oJson as core.Map<core.String, core.dynamic>); |
| checkRemoveFirebaseRequest(od); |
| }); |
| }); |
| |
| unittest.group('resource-ProjectsBucketsResource', () { |
| unittest.test('method--addFirebase', () async { |
| final mock = HttpServerMock(); |
| final res = api.FirebasestorageApi(mock).projects.buckets; |
| final arg_request = buildAddFirebaseRequest(); |
| final arg_bucket = 'foo'; |
| final arg_$fields = 'foo'; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| final obj = api.AddFirebaseRequest.fromJson( |
| json as core.Map<core.String, core.dynamic>); |
| checkAddFirebaseRequest(obj); |
| |
| final path = (req.url).path; |
| var pathOffset = 0; |
| core.int index; |
| core.String subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), |
| unittest.equals('/'), |
| ); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 7), |
| unittest.equals('v1beta/'), |
| ); |
| pathOffset += 7; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| final query = (req.url).query; |
| var queryOffset = 0; |
| final queryMap = <core.String, core.List<core.String>>{}; |
| void addQueryParam(core.String n, core.String v) => |
| queryMap.putIfAbsent(n, () => []).add(v); |
| |
| if (query.isNotEmpty) { |
| for (var part in query.split('&')) { |
| final keyValue = part.split('='); |
| addQueryParam( |
| core.Uri.decodeQueryComponent(keyValue[0]), |
| core.Uri.decodeQueryComponent(keyValue[1]), |
| ); |
| } |
| } |
| unittest.expect( |
| queryMap['fields']!.first, |
| unittest.equals(arg_$fields), |
| ); |
| |
| final h = { |
| 'content-type': 'application/json; charset=utf-8', |
| }; |
| final resp = convert.json.encode(buildBucket()); |
| return async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| final response = |
| await res.addFirebase(arg_request, arg_bucket, $fields: arg_$fields); |
| checkBucket(response as api.Bucket); |
| }); |
| |
| unittest.test('method--get', () async { |
| final mock = HttpServerMock(); |
| final res = api.FirebasestorageApi(mock).projects.buckets; |
| final arg_name = 'foo'; |
| final arg_$fields = 'foo'; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| final path = (req.url).path; |
| var pathOffset = 0; |
| core.int index; |
| core.String subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), |
| unittest.equals('/'), |
| ); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 7), |
| unittest.equals('v1beta/'), |
| ); |
| pathOffset += 7; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| final query = (req.url).query; |
| var queryOffset = 0; |
| final queryMap = <core.String, core.List<core.String>>{}; |
| void addQueryParam(core.String n, core.String v) => |
| queryMap.putIfAbsent(n, () => []).add(v); |
| |
| if (query.isNotEmpty) { |
| for (var part in query.split('&')) { |
| final keyValue = part.split('='); |
| addQueryParam( |
| core.Uri.decodeQueryComponent(keyValue[0]), |
| core.Uri.decodeQueryComponent(keyValue[1]), |
| ); |
| } |
| } |
| unittest.expect( |
| queryMap['fields']!.first, |
| unittest.equals(arg_$fields), |
| ); |
| |
| final h = { |
| 'content-type': 'application/json; charset=utf-8', |
| }; |
| final resp = convert.json.encode(buildBucket()); |
| return async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| final response = await res.get(arg_name, $fields: arg_$fields); |
| checkBucket(response as api.Bucket); |
| }); |
| |
| unittest.test('method--list', () async { |
| final mock = HttpServerMock(); |
| final res = api.FirebasestorageApi(mock).projects.buckets; |
| final arg_parent = 'foo'; |
| final arg_pageSize = 42; |
| final arg_pageToken = 'foo'; |
| final arg_$fields = 'foo'; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| final path = (req.url).path; |
| var pathOffset = 0; |
| core.int index; |
| core.String subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), |
| unittest.equals('/'), |
| ); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 7), |
| unittest.equals('v1beta/'), |
| ); |
| pathOffset += 7; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| final query = (req.url).query; |
| var queryOffset = 0; |
| final queryMap = <core.String, core.List<core.String>>{}; |
| void addQueryParam(core.String n, core.String v) => |
| queryMap.putIfAbsent(n, () => []).add(v); |
| |
| if (query.isNotEmpty) { |
| for (var part in query.split('&')) { |
| final keyValue = part.split('='); |
| addQueryParam( |
| core.Uri.decodeQueryComponent(keyValue[0]), |
| core.Uri.decodeQueryComponent(keyValue[1]), |
| ); |
| } |
| } |
| unittest.expect( |
| core.int.parse(queryMap['pageSize']!.first), |
| unittest.equals(arg_pageSize), |
| ); |
| unittest.expect( |
| queryMap['pageToken']!.first, |
| unittest.equals(arg_pageToken), |
| ); |
| unittest.expect( |
| queryMap['fields']!.first, |
| unittest.equals(arg_$fields), |
| ); |
| |
| final h = { |
| 'content-type': 'application/json; charset=utf-8', |
| }; |
| final resp = convert.json.encode(buildListBucketsResponse()); |
| return async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| final response = await res.list(arg_parent, |
| pageSize: arg_pageSize, |
| pageToken: arg_pageToken, |
| $fields: arg_$fields); |
| checkListBucketsResponse(response as api.ListBucketsResponse); |
| }); |
| |
| unittest.test('method--removeFirebase', () async { |
| final mock = HttpServerMock(); |
| final res = api.FirebasestorageApi(mock).projects.buckets; |
| final arg_request = buildRemoveFirebaseRequest(); |
| final arg_bucket = 'foo'; |
| final arg_$fields = 'foo'; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| final obj = api.RemoveFirebaseRequest.fromJson( |
| json as core.Map<core.String, core.dynamic>); |
| checkRemoveFirebaseRequest(obj); |
| |
| final path = (req.url).path; |
| var pathOffset = 0; |
| core.int index; |
| core.String subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), |
| unittest.equals('/'), |
| ); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 7), |
| unittest.equals('v1beta/'), |
| ); |
| pathOffset += 7; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| final query = (req.url).query; |
| var queryOffset = 0; |
| final queryMap = <core.String, core.List<core.String>>{}; |
| void addQueryParam(core.String n, core.String v) => |
| queryMap.putIfAbsent(n, () => []).add(v); |
| |
| if (query.isNotEmpty) { |
| for (var part in query.split('&')) { |
| final keyValue = part.split('='); |
| addQueryParam( |
| core.Uri.decodeQueryComponent(keyValue[0]), |
| core.Uri.decodeQueryComponent(keyValue[1]), |
| ); |
| } |
| } |
| unittest.expect( |
| queryMap['fields']!.first, |
| unittest.equals(arg_$fields), |
| ); |
| |
| final h = { |
| 'content-type': 'application/json; charset=utf-8', |
| }; |
| final resp = convert.json.encode(buildEmpty()); |
| return async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| final response = await res.removeFirebase(arg_request, arg_bucket, |
| $fields: arg_$fields); |
| checkEmpty(response as api.Empty); |
| }); |
| }); |
| } |