Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests for onSendProgress #1991

Merged
merged 8 commits into from
Oct 13, 2023
Merged

Added tests for onSendProgress #1991

merged 8 commits into from
Oct 13, 2023

Conversation

SpeedReach
Copy link
Contributor

New Pull Request Checklist

  • I have read the Documentation
  • I have searched for a similar pull request in the project and found none
  • I have updated this branch with the latest main branch to avoid conflicts (via merge from master or rebase)
  • I have added the required tests to prove the fix/feature I'm adding
  • I have updated the documentation (if necessary)
  • I have run the tests without failures
  • I have updated the CHANGELOG.md in the corresponding package

Additional context and info (if any)

@SpeedReach SpeedReach requested a review from a team as a code owner October 5, 2023 10:36
options: Options(
contentType: Headers.textPlainContentType,
headers: {
Headers.contentLengthHeader: data.length * 2, // set content-length
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean 5 * 2 right? We should use data.expand to get the length without magic calculations.

),
);
for (int i = 0; i < data.length; i++) {
expect(collected[i], (i + 1) * 2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

'/put',
data: stream,
onSendProgress: (a, b) {
expect(b, 10);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as others. Once we modified the bytes, 10 becomes invalid and no one knows what it means.

@SpeedReach
Copy link
Contributor Author

SpeedReach commented Oct 6, 2023

@AlexV525 Thanks for the review! I changed the code above, it allows any data bytes length now.

@AlexV525
Copy link
Member

AlexV525 commented Oct 6, 2023

I saw tests failed, could you resolve them?

@SpeedReach
Copy link
Contributor Author

SpeedReach commented Oct 6, 2023

Hi @AlexV525
I found that the reason browser's tests do not pass is because it has different implementations.
The browser one triggers progressEvent only once , so onSendProgress only has two states, 0% and 100%, this should be related to this issue.
However I changed the tests, and they should pass now.
Let me know if there are any further modifications needed.

@AlexV525
Copy link
Member

AlexV525 commented Oct 9, 2023

The browser one triggers progressEvent only once , so onSendProgress only has two states, 0% and 100%, this should be related to this issue.

Consider adding the ref as a TODO?

@SpeedReach
Copy link
Contributor Author

I could give it a try but I havn't worked on a sdk before.
Should I open a issue for tracking it?

@SpeedReach
Copy link
Contributor Author

SpeedReach commented Oct 9, 2023

By the way this pull request tests if the onSendProgress is triggered properly, but not how frequently it is triggered, since dio isn't responsible for it.

@AlexV525
Copy link
Member

AlexV525 commented Oct 9, 2023

What I mean is to write a TODO comment like:

// TODO(anyone): Update the test once https://github.com/dart-lang/sdk/issues/43904 has been resolved.

But it doesn't matter at this point, since the tests didn't count on Web-specific codes.

Copy link
Member

@AlexV525 AlexV525 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SpeedReach
Copy link
Contributor Author

I don't have the permission to merge it.Could you help me merge?

@AlexV525 AlexV525 added this pull request to the merge queue Oct 13, 2023
Merged via the queue into cfug:main with commit 2fbd0a5 Oct 13, 2023
30 checks passed
@AlexV525 AlexV525 added p: dio Targeting `dio` package e: tests Improvements or additions to tests labels Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e: tests Improvements or additions to tests p: dio Targeting `dio` package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants