Re-generate built_value classes (#587)

pull/591/head
Brett Morgan 5 years ago committed by GitHub
parent 98574d1844
commit 25bfc7846d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -53,7 +53,7 @@ class _$SearchSerializer implements StructuredSerializer<Search> {
result.results.replace(serializers.deserialize(value, result.results.replace(serializers.deserialize(value,
specifiedType: specifiedType:
const FullType(BuiltList, const [const FullType(Photo)])) const FullType(BuiltList, const [const FullType(Photo)]))
as BuiltList<dynamic>); as BuiltList<Object>);
break; break;
} }
} }

@ -46,7 +46,7 @@ class _$ApiErrorSerializer implements StructuredSerializer<ApiError> {
result.errors.replace(serializers.deserialize(value, result.errors.replace(serializers.deserialize(value,
specifiedType: specifiedType:
const FullType(BuiltList, const [const FullType(String)])) const FullType(BuiltList, const [const FullType(String)]))
as BuiltList<dynamic>); as BuiltList<Object>);
break; break;
} }
} }

@ -189,13 +189,13 @@ class _$PhotoSerializer implements StructuredSerializer<Photo> {
result.tags.replace(serializers.deserialize(value, result.tags.replace(serializers.deserialize(value,
specifiedType: specifiedType:
const FullType(BuiltList, const [const FullType(Tags)])) const FullType(BuiltList, const [const FullType(Tags)]))
as BuiltList<dynamic>); as BuiltList<Object>);
break; break;
case 'current_user_collections': case 'current_user_collections':
result.currentUserCollections.replace(serializers.deserialize(value, result.currentUserCollections.replace(serializers.deserialize(value,
specifiedType: const FullType(BuiltList, const [ specifiedType: const FullType(BuiltList, const [
const FullType(CurrentUserCollections) const FullType(CurrentUserCollections)
])) as BuiltList<dynamic>); ])) as BuiltList<Object>);
break; break;
case 'urls': case 'urls':
result.urls.replace(serializers.deserialize(value, result.urls.replace(serializers.deserialize(value,

@ -72,7 +72,7 @@ class _$SearchPhotosResponseSerializer
result.results.replace(serializers.deserialize(value, result.results.replace(serializers.deserialize(value,
specifiedType: specifiedType:
const FullType(BuiltList, const [const FullType(Photo)])) const FullType(BuiltList, const [const FullType(Photo)]))
as BuiltList<dynamic>); as BuiltList<Object>);
break; break;
} }
} }

@ -36,4 +36,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: d8ba9b3e9e93c62c74a660b46c6fcb09f03991a7 PODFILE CHECKSUM: d8ba9b3e9e93c62c74a660b46c6fcb09f03991a7
COCOAPODS: 1.9.1 COCOAPODS: 1.9.3

@ -339,9 +339,198 @@ void main() {
await unsplashClient.searchPhotos(query: 'red'); await unsplashClient.searchPhotos(query: 'red');
fail('UnsplashException should have been thrown'); fail('UnsplashException should have been thrown');
} on UnsplashException catch (e) { } on UnsplashException catch (e) {
expect(e.toString(), expect(e.toString(), 'UnsplashException: Invalid JSON received');
'UnsplashException: Invalid JSON received'); }
});
});
test('handles utf8 content in JSON', () async {
const searchPhotosResponseBody = '''
{
"total": 22395,
"total_pages": 2240,
"results": [
{
"id": "E4u_Zo9PET8",
"created_at": "2019-12-29T13:45:28-05:00",
"updated_at": "2020-11-05T17:12:18-05:00",
"promoted_at": null,
"width": 2598,
"height": 4618,
"color": "#A53E40",
"blur_hash": "LlO{8lL#XSbu*Jtla0jZOrb^ozjF",
"description": null,
"alt_description": "red apparel",
"urls": {
"raw": "https://images.unsplash.com/photo-1577645113639-32537a4a938b?ixlib=rb-1.2.1\u0026ixid=eyJhcHBfaWQiOjM5NTU5fQ",
"full": "https://images.unsplash.com/photo-1577645113639-32537a4a938b?ixlib=rb-1.2.1\u0026q=85\u0026fm=jpg\u0026crop=entropy\u0026cs=srgb\u0026ixid=eyJhcHBfaWQiOjM5NTU5fQ",
"regular": "https://images.unsplash.com/photo-1577645113639-32537a4a938b?ixlib=rb-1.2.1\u0026q=80\u0026fm=jpg\u0026crop=entropy\u0026cs=tinysrgb\u0026w=1080\u0026fit=max\u0026ixid=eyJhcHBfaWQiOjM5NTU5fQ",
"small": "https://images.unsplash.com/photo-1577645113639-32537a4a938b?ixlib=rb-1.2.1\u0026q=80\u0026fm=jpg\u0026crop=entropy\u0026cs=tinysrgb\u0026w=400\u0026fit=max\u0026ixid=eyJhcHBfaWQiOjM5NTU5fQ",
"thumb": "https://images.unsplash.com/photo-1577645113639-32537a4a938b?ixlib=rb-1.2.1\u0026q=80\u0026fm=jpg\u0026crop=entropy\u0026cs=tinysrgb\u0026w=200\u0026fit=max\u0026ixid=eyJhcHBfaWQiOjM5NTU5fQ"
},
"links": {
"self": "https://api.unsplash.com/photos/E4u_Zo9PET8",
"html": "https://unsplash.com/photos/E4u_Zo9PET8",
"download": "https://unsplash.com/photos/E4u_Zo9PET8/download",
"download_location": "https://api.unsplash.com/photos/E4u_Zo9PET8/download"
},
"categories": [],
"likes": 132,
"liked_by_user": false,
"current_user_collections": [],
"sponsorship": null,
"user": {
"id": "_2nQcPrbyuE",
"updated_at": "2020-11-06T01:37:51-05:00",
"username": "svalenas",
"name": "Sergiu Vălenaș",
"first_name": "Sergiu",
"last_name": "Vălenaș",
"twitter_username": null,
"portfolio_url": null,
"bio": "Gifted psychologist and enthusiast photographer",
"location": "Cluj-Napoca, Romania",
"links": {
"self": "https://api.unsplash.com/users/svalenas",
"html": "https://unsplash.com/@svalenas",
"photos": "https://api.unsplash.com/users/svalenas/photos",
"likes": "https://api.unsplash.com/users/svalenas/likes",
"portfolio": "https://api.unsplash.com/users/svalenas/portfolio",
"following": "https://api.unsplash.com/users/svalenas/following",
"followers": "https://api.unsplash.com/users/svalenas/followers"
},
"profile_image": {
"small": "https://images.unsplash.com/profile-1597067601066-d43176d68553image?ixlib=rb-1.2.1\u0026q=80\u0026fm=jpg\u0026crop=faces\u0026cs=tinysrgb\u0026fit=crop\u0026h=32\u0026w=32",
"medium": "https://images.unsplash.com/profile-1597067601066-d43176d68553image?ixlib=rb-1.2.1\u0026q=80\u0026fm=jpg\u0026crop=faces\u0026cs=tinysrgb\u0026fit=crop\u0026h=64\u0026w=64",
"large": "https://images.unsplash.com/profile-1597067601066-d43176d68553image?ixlib=rb-1.2.1\u0026q=80\u0026fm=jpg\u0026crop=faces\u0026cs=tinysrgb\u0026fit=crop\u0026h=128\u0026w=128"
},
"instagram_username": "svalenas",
"total_collections": 0,
"total_likes": 413,
"total_photos": 129,
"accepted_tos": true
},
"tags": [
{
"type": "landing_page",
"title": "red",
"source": {
"ancestry": {
"type": {
"slug": "wallpapers",
"pretty_slug": "HD Wallpapers"
},
"category": {
"slug": "colors",
"pretty_slug": "Color"
},
"subcategory": {
"slug": "red",
"pretty_slug": "Red"
}
},
"title": "HD Red Wallpapers",
"subtitle": "Download Free Red Wallpapers",
"description": "Choose from a curated selection of red wallpapers for your mobile and desktop screens. Always free on Unsplash.",
"meta_title": "Red Wallpapers: Free HD Download [500+ HQ] | Unsplash",
"meta_description": "Choose from hundreds of free red wallpapers. Download HD wallpapers for free on Unsplash.",
"cover_photo": {
"id": "HyBXy5PHQR8",
"created_at": "2018-02-17T13:44:58-05:00",
"updated_at": "2020-10-21T01:07:42-04:00",
"promoted_at": null,
"width": 3024,
"height": 4032,
"color": "#C51918",
"blur_hash": "L9Bmx_o1o1Jl|cwxWpWpN]\$5N]sU",
"description": null,
"alt_description": "red textile",
"urls": {
"raw": "https://images.unsplash.com/photo-1518893063132-36e46dbe2428?ixlib=rb-1.2.1",
"full": "https://images.unsplash.com/photo-1518893063132-36e46dbe2428?ixlib=rb-1.2.1\u0026q=85\u0026fm=jpg\u0026crop=entropy\u0026cs=srgb",
"regular": "https://images.unsplash.com/photo-1518893063132-36e46dbe2428?ixlib=rb-1.2.1\u0026q=80\u0026fm=jpg\u0026crop=entropy\u0026cs=tinysrgb\u0026w=1080\u0026fit=max",
"small": "https://images.unsplash.com/photo-1518893063132-36e46dbe2428?ixlib=rb-1.2.1\u0026q=80\u0026fm=jpg\u0026crop=entropy\u0026cs=tinysrgb\u0026w=400\u0026fit=max",
"thumb": "https://images.unsplash.com/photo-1518893063132-36e46dbe2428?ixlib=rb-1.2.1\u0026q=80\u0026fm=jpg\u0026crop=entropy\u0026cs=tinysrgb\u0026w=200\u0026fit=max"
},
"links": {
"self": "https://api.unsplash.com/photos/HyBXy5PHQR8",
"html": "https://unsplash.com/photos/HyBXy5PHQR8",
"download": "https://unsplash.com/photos/HyBXy5PHQR8/download",
"download_location": "https://api.unsplash.com/photos/HyBXy5PHQR8/download"
},
"categories": [],
"likes": 1243,
"liked_by_user": false,
"current_user_collections": [],
"sponsorship": null,
"user": {
"id": "6nkkrwW9M-s",
"updated_at": "2020-10-22T20:44:54-04:00",
"username": "montylov",
"name": "MontyLov",
"first_name": "MontyLov",
"last_name": null,
"twitter_username": "MontyLov",
"portfolio_url": "http://montylov.com",
"bio": "Stay humble and innovate.",
"location": null,
"links": {
"self": "https://api.unsplash.com/users/montylov",
"html": "https://unsplash.com/@montylov",
"photos": "https://api.unsplash.com/users/montylov/photos",
"likes": "https://api.unsplash.com/users/montylov/likes",
"portfolio": "https://api.unsplash.com/users/montylov/portfolio",
"following": "https://api.unsplash.com/users/montylov/following",
"followers": "https://api.unsplash.com/users/montylov/followers"
},
"profile_image": {
"small": "https://images.unsplash.com/profile-1588478301600-b5e5203a574aimage?ixlib=rb-1.2.1\u0026q=80\u0026fm=jpg\u0026crop=faces\u0026cs=tinysrgb\u0026fit=crop\u0026h=32\u0026w=32",
"medium": "https://images.unsplash.com/profile-1588478301600-b5e5203a574aimage?ixlib=rb-1.2.1\u0026q=80\u0026fm=jpg\u0026crop=faces\u0026cs=tinysrgb\u0026fit=crop\u0026h=64\u0026w=64",
"large": "https://images.unsplash.com/profile-1588478301600-b5e5203a574aimage?ixlib=rb-1.2.1\u0026q=80\u0026fm=jpg\u0026crop=faces\u0026cs=tinysrgb\u0026fit=crop\u0026h=128\u0026w=128"
},
"instagram_username": "montylov",
"total_collections": 1,
"total_likes": 0,
"total_photos": 79,
"accepted_tos": false
}
}
}
},
{
"type": "search",
"title": "rug"
},
{
"type": "search",
"title": "plant"
}
]
}
]
} }
''';
final httpClient = MockClient((req) async {
return Response(
searchPhotosResponseBody,
200,
request: req,
headers: {'content-type': 'application/json; charset=utf-8'},
);
}); });
final unsplashClient = Unsplash(
accessKey: 'not-an-access-key',
httpClient: httpClient,
);
final response = await unsplashClient.searchPhotos(query: 'red');
expect(response.total, 22395);
expect(response.totalPages, 2240);
expect(response.results[0].id, 'E4u_Zo9PET8');
expect(response.results[0].user.id, '_2nQcPrbyuE');
expect(response.results[0].user.name, 'Sergiu Vălenaș');
}); });
} }

Loading…
Cancel
Save