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

ShouldHaveCalled gives false negative when called URL ends with "?" #721

Closed
cesit-nav opened this issue Oct 14, 2022 · 3 comments
Closed
Labels

Comments

@cesit-nav
Copy link

I am creating unit testing for flur call with multipal SetQueryParam it is throwing error like below

Flurl.Http.Testing.HttpTestException: 'Expected any calls to be made with URL pattern https://stamped.io/api/widget/reviews?, but no matching calls were made.'

Please let me know what is going wrong here.
please check first screen shot is for actual call and second is for unit test

image
image

@cesit-nav cesit-nav added the bug label Oct 14, 2022
@tmenier
Copy link
Owner

tmenier commented Oct 21, 2022

Does PublicReviewsWithFilter actually contain a trailing ?? If so remove the ? from that constant. It's not necessary for SetQueryParam and it might be confusing ShouldHaveCalled, which has special logic for ignoring query strings.

@tmenier
Copy link
Owner

tmenier commented Nov 18, 2022

Confirmed there's a bug here. (As a side note, if you had provided a minimal, isolated example such as below, it would have helped me understand this much sooner. But I got there anyway. 😉)

[TestCase("https://api.com/foo?", "https://api.com/foo?")] // fail
[TestCase("https://api.com/foo", "https://api.com/foo?")]  // pass
[TestCase("https://api.com/foo?", "https://api.com/foo")]  // fail
public async Task bug_721(string actual, string expected) {
	using var httpTest = new HttpTest();
	var x = await actual.GetAsync();
	httpTest.ShouldHaveCalled(expected);
}

@tmenier tmenier changed the title 'Expected any calls to be made with URL pattern https:... but no matching calls were made.' ShouldHaveCalled gives false negative when called URL ends with "?" Nov 18, 2022
@tmenier
Copy link
Owner

tmenier commented Dec 19, 2022

This wasn't a bug actually a bug in HttpTest like I suspected but rather a side-effect of #734

tmenier added a commit that referenced this issue Dec 19, 2022
@tmenier tmenier closed this as completed Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Released
Development

No branches or pull requests

2 participants