Skip to content
This repository was archived by the owner on Aug 18, 2021. It is now read-only.

feat(Polly): simplify ternary unit tests #223

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

av-linasuzuki
Copy link

issue #113
simplify ternary in Polly and created the unit test about this class

@bruno-brant
Copy link
Contributor

Hi @av-linasuzuki could you review your commit messages and follow the current standard? It's not documented in the contribution guide (that's my failure) but nonetheless there's a standard.

For practical examples, see the commit history of the project.

For the syntax itself, check here.

If you need help changing previous commit messages, take a look here. If you need help, get in touch with me directly. Thanks!

Copy link
Contributor

@bruno-brant bruno-brant left a comment

Choose a reason for hiding this comment

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

This is a preliminary review since the PR is failing to build. I've made some suggestions as well as some requests. Fell free to drop me a comment if you have questions!

@av-linasuzuki av-linasuzuki force-pushed the feature/Simplify-Ternary branch from 6767f8f to 0e8a427 Compare May 5, 2020 20:34
@ying-feifan-avanade ying-feifan-avanade force-pushed the feature/Simplify-Ternary branch from 0e8a427 to 432c761 Compare May 5, 2020 20:46
@av-linasuzuki av-linasuzuki force-pushed the feature/Simplify-Ternary branch from 432c761 to e1cc147 Compare May 6, 2020 15:07
@bavanade
Copy link
Contributor

bavanade commented May 7, 2020

@av-linasuzuki @ying-feifan-avanade please include in the PR description a command to close the issue, as described here: https://help.github.com/en/enterprise/2.16/user/github/managing-your-work-on-github/closing-issues-using-keywords

(You can edit the description of the issue by clicking the ellipsis "..." on the top-right side of the textbox)

Copy link
Contributor

@bavanade bavanade left a comment

Choose a reason for hiding this comment

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

I'm pointing out a few minor changes, but there are some important things to note:

  • Tests depend on external conditions, for instance, that URL https://www.aipdhapsidh.com be invalid. If, for instance, I were to register said URL now, our test would fail.

  • The tests don't actually tests the declared conditions. For instance, ResilientRequestWhenInvalidUrlAfterRetriedConfiguredAttempsThrowHttpRequest explicitly states that the throw is made after configured attempts. However, we don't check how many times the request was made and, therefore, can't know for sure if polly is doing what it is expected. Same can be said of the other tests.

One way around those two issues is to start a mock server which you will call using polly, as I did while testing LiquidApi. You can check on the mock side if n calls where made, and that would be enough.

Testing the backOffTime is a bit more hard, since the time informed and the time measured will conflict, but you could try measuring with a very small value and then with a large value, which would prove that a delay was applied.

Comment on lines 48 to 60
[Fact]
public async Task ResilientRequestShouldUseDefaultPollyConfigAsRetryAttemptWhenIsBackOffFalse()
{
//Arrange
PollyConfiguration _pollyConfiguration = new PollyConfiguration { IsBackOff = false, Retry = 3, Wait = 5 };
var url = "https://www.google.com";
//Action
using (HttpResponseMessage result = await _sut.ResilientRequest(url, _httpClient, _http, _pollyConfiguration).ConfigureAwait(false))
{
//Assert
Assert.True(result.IsSuccessStatusCode);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please tell me the difference between this test and the previous one? They seem to be exactly the same.

Copy link
Author

Choose a reason for hiding this comment

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

We tried to test for a false return but failed.
Can we leave without this test?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants