Skip to content

chore: fix bugs and add more tests - #169

Closed
techouse wants to merge 7 commits into
CodingAleCR:mainfrom
techouse:chore/tests
Closed

chore: fix bugs and add more tests#169
techouse wants to merge 7 commits into
CodingAleCR:mainfrom
techouse:chore/tests

Conversation

@techouse

@techousetechouse commented Jul 23, 2025

Copy link
Copy Markdown
Contributor

This pull request introduces significant updates to the copyWith methods for BaseRequest, StreamedRequest, and related classes, transitioning them to asynchronous operations. It also adds comprehensive test coverage for these changes, ensuring correctness and robustness. Below are the key changes grouped by theme:

Enhancements to copyWith Methods:

  • The copyWith method in BaseRequest was updated to be asynchronous (Future<BaseRequest>), enabling support for asynchronous operations like handling streams. (lib/extensions/base_request.dart, [1][2][3]
  • Similarly, the StreamedRequest.copyWith method was updated to be asynchronous and now uses await to handle streams properly. (lib/extensions/streamed_request.dart, lib/extensions/streamed_request.dartL8-R29)

Bug Fixes and Improvements:

  • Fixed a bug where copyWith methods for StreamedRequest and MultipartRequest incorrectly modified the original request's properties (e.g., followRedirects, maxRedirects, persistentConnection). (test/extensions/multipart_request_test.dart, test/extensions/multipart_request_test.dartR1-R186)

Updates to Intercepted Client:

  • Updated the _interceptRequest method in InterceptedClient to await the asynchronous copyWith method, ensuring compatibility with the updated BaseRequest. (lib/http/intercepted_client.dart, lib/http/intercepted_client.dartL400-R400)

Comprehensive Test Coverage:

  • Added new tests for BaseRequest.copyWith, StreamedRequest.copyWith, MultipartRequest.copyWith, and IOStreamedResponse.copyWith, covering edge cases, property overrides, and unsupported types. (test/extensions/base_request_test.dart, [1]; test/extensions/io_streamed_response_test.dart, [2]; test/extensions/multipart_request_test.dart, [3]
  • Introduced tests to validate proper handling of unsupported request and response types, ensuring UnsupportedError is thrown as expected. (test/extensions/base_request_test.dart, [1]; test/extensions/base_reponse_test.dart, [2]

Miscellaneous Changes:

  • Added missing imports for dart:async and dart:convert in various files to support asynchronous operations and data encoding. (lib/extensions/base_request.dart, [1]; test/extensions/base_reponse_test.dart, [2]

These changes collectively modernize the copyWith implementation, making it more robust and suitable for handling complex request and response scenarios while ensuring backward compatibility through extensive testing.

@techousetechouse changed the title 🧪 add more tests✅ add more testsJul 23, 2025
@techousetechouse changed the title ✅ add more testschore: add more testsJul 23, 2025
@techouse

techouse commented Jul 23, 2025

Copy link
Copy Markdown
ContributorAuthor

@CodingAleCR you could potentially merge these tests with the ones in #167

@techousetechouse changed the title chore: add more testschore: fix bugs and add more testsJul 26, 2025
@techousetechouse mentioned this pull request Jul 26, 2025
9 tasks
@CodingAleCR

Copy link
Copy Markdown
Owner

Hey @techouse Sorry it took me a year to get to this.

I ended up deciding on doing a full rewrite of the library to avoid copyWith issues amongst other things. Please take a look at #173 if it makes sense for you, I can also understand if you no longer have interest in this package due to slow responses. Thank you anyway!

@techouse

Copy link
Copy Markdown
ContributorAuthor

Hi @CodingAleCR

No worries. I completely understand that sometimes life comes in the way.

I'll check it out in the evening 😊

@techouse
techouse deleted the chore/tests branch March 18, 2026 08:54
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@techouse@CodingAleCR