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

fix multi enumeration bug #318

Merged
merged 2 commits into from
Apr 26, 2021
Merged

fix multi enumeration bug #318

merged 2 commits into from
Apr 26, 2021

Conversation

SimonCropp
Copy link
Contributor

No description provided.

@SimonCropp SimonCropp requested a review from a team as a code owner April 24, 2021 01:41
Copy link
Member

@martincostello martincostello left a comment

Choose a reason for hiding this comment

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

Nice catch. Would you mind adding a unit test for the bug please?

@martincostello martincostello added this to the Future milestone Apr 24, 2021
@martincostello martincostello added the bug A defect in the code or documentation. label Apr 24, 2021
@codecov-commenter
Copy link

codecov-commenter commented Apr 24, 2021

Codecov Report

Merging #318 (98203d0) into main (0f89fb2) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #318   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           16        16           
  Lines         1128      1129    +1     
=========================================
+ Hits          1128      1129    +1     
Flag Coverage Δ
linux 100.00% <100.00%> (ø)
macos 100.00% <100.00%> (ø)
windows 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/HttpClientInterception/BundleExtensions.cs 100.00% <100.00%> (ø)
...ientInterception/HttpRequestInterceptionBuilder.cs 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f89fb2...98203d0. Read the comment docs.

@martincostello martincostello modified the milestones: Future, v3.1.1 Apr 24, 2021
@SimonCropp
Copy link
Contributor Author

is there a test that passes multiple items ?

@martincostello
Copy link
Member

Doesn't look like it, which I guess is why the bug you've found is there.

The templating tests are here: https://github.com/justeat/httpclient-interception/blob/cbe05bf80a1a06c8086482c04393bc174b958ac2/tests/HttpClientInterception.Tests/Bundles/BundleExtensionsTests.cs#L168-L241

@SimonCropp
Copy link
Contributor Author

i dont have adequate understanding of this library to produce a test for this bug. but if u have a forward only enumerator (eg from a method that yields), and you have multiple bundle.Items, then BundleItemConverter.FromItem will move the enumerator multiple times. eg if u have 1 templateValues and 2 bundle.Items, then BundleItemConverter.FromItem will only get the 1 templateValues on the first call. the second call to FromItem the enumerator will be empty

@martincostello
Copy link
Member

So this is a bug you found purely from reading the code, rather than you trying to do something specific with it and it throwing an exception?

@SimonCropp
Copy link
Contributor Author

So this is a bug you found purely from reading the code

resharper highlighted it as an error

It's a list of templates, not multiple lists of a template.
@martincostello martincostello added enhancement A change that enhances existing functionality or documentation. and removed bug A defect in the code or documentation. labels Apr 26, 2021
@martincostello martincostello merged commit 46316fa into justeattakeaway:main Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A change that enhances existing functionality or documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants