From 2d0082f3b01ecd78ebcc0436c98b0efb34b3fe86 Mon Sep 17 00:00:00 2001 From: "thomashii@dukefirehawk.com" Date: Sun, 28 Aug 2022 22:11:10 +0800 Subject: [PATCH] Fixed body_parser analysis warnings --- packages/body_parser/CHANGELOG.md | 4 ++++ packages/body_parser/pubspec.yaml | 4 ++-- packages/body_parser/test/form_data_test.dart | 6 ++---- packages/body_parser/test/server_test.dart | 10 +++++----- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/body_parser/CHANGELOG.md b/packages/body_parser/CHANGELOG.md index 4004393..60d76d7 100644 --- a/packages/body_parser/CHANGELOG.md +++ b/packages/body_parser/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 4.0.1 + +* Updated `belatuk_http_server` to 3.0.0 + ## 4.0.0 * Require Dart >= 2.17 diff --git a/packages/body_parser/pubspec.yaml b/packages/body_parser/pubspec.yaml index cad96de..1134321 100644 --- a/packages/body_parser/pubspec.yaml +++ b/packages/body_parser/pubspec.yaml @@ -1,12 +1,12 @@ name: belatuk_body_parser -version: 4.0.0 +version: 4.0.1 description: Parse request bodies and query strings in Dart. Supports JSON, URL-encoded, and multi-part bodies. homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/body_parser environment: sdk: '>=2.17.0 <3.0.0' dependencies: http_parser: ^4.0.0 - belatuk_http_server: ^2.0.0 + belatuk_http_server: ^3.0.0 mime: ^1.0.0 dev_dependencies: http: ^0.13.0 diff --git a/packages/body_parser/test/form_data_test.dart b/packages/body_parser/test/form_data_test.dart index 87fb4bc..d4cc3aa 100644 --- a/packages/body_parser/test/form_data_test.dart +++ b/packages/body_parser/test/form_data_test.dart @@ -63,10 +63,8 @@ world print('Response: ${response.body}'); var jsons = json.decode(response.body); var files = jsons['files'].map((map) { - return map == null - ? null - : map.keys.fold>( - {}, (out, k) => out..[k.toString()] = map[k]); + return map.keys.fold>( + {}, (out, k) => out..[k.toString()] = map[k]); }); expect(files.length, equals(0)); expect(jsons['body']['hello'], equals('world')); diff --git a/packages/body_parser/test/server_test.dart b/packages/body_parser/test/server_test.dart index ee0048b..2a690f4 100644 --- a/packages/body_parser/test/server_test.dart +++ b/packages/body_parser/test/server_test.dart @@ -6,7 +6,7 @@ import 'package:http/http.dart' as http; import 'package:http_parser/http_parser.dart'; import 'package:test/test.dart'; -const TOKEN = +const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiIxMjcuMC4wLjEiLCJleHAiOi0xLCJpYXQiOiIyMDE2LTEyLTIyVDEyOjQ5OjUwLjM2MTQ0NiIsImlzcyI6ImFuZ2VsX2F1dGgiLCJzdWIiOiIxMDY2OTQ4Mzk2MDIwMjg5ODM2NTYifQ==.PYw7yUb-cFWD7N0sSLztP7eeRvO44nu1J2OgDNyT060='; String jsonEncodeBody(BodyParseResult result) { @@ -89,12 +89,12 @@ void main() { }); test('JWT', () async { - var postData = 'token=$TOKEN'; + var postData = 'token=$token'; print('Body: $postData'); var response = await client!.get(Uri.parse('$url/?$postData')); print('Response: ${response.body}'); var query = json.decode(response.body)['query']; - expect(query['token'], equals(TOKEN)); + expect(query['token'], equals(token)); }); }); @@ -129,11 +129,11 @@ void main() { }); test('JWT', () async { - var postData = 'token=$TOKEN'; + var postData = 'token=$token'; var response = await client!.post(Uri.parse(url!), headers: headers, body: postData); var body = json.decode(response.body)['body']; - expect(body['token'], equals(TOKEN)); + expect(body['token'], equals(token)); }); });