Skip to content

Re-write the RetryPolicy unit tests to remove strong coupling with implementation detail which are marked as virtual for mocking  #5585

@ahsonkhan

Description

@ahsonkhan

Follow-up from #5584
Currently the RetryPolicy has these two methods which are part of its implementation detail and being used in unit tests:

  • ShouldRetryOnResponse
  • ShouldRetryOnTransportFailure

protected:
virtual bool ShouldRetryOnTransportFailure(
RetryOptions const& retryOptions,
int32_t attempt,
std::chrono::milliseconds& retryAfter,
double jitterFactor = -1) const;
virtual bool ShouldRetryOnResponse(
RawResponse const& response,
RetryOptions const& retryOptions,
int32_t attempt,
std::chrono::milliseconds& retryAfter,
double jitterFactor = -1) const;

These methods don't need to be virtual nor are they part of the public surface area. However, the way the tests are written, they take a dependency on this implementation detail. Additionally, because the unit tests have them mocked, they have to be marked as virtual, which they shouldn't be.

protected:
bool ShouldRetryOnTransportFailure(
RetryOptions const& retryOptions,
int32_t attempt,
std::chrono::milliseconds& retryAfter,
double jitterFactor) const override
{
return m_shouldRetryOnTransportFailure(retryOptions, attempt, retryAfter, jitterFactor);
}
bool ShouldRetryOnResponse(
RawResponse const& response,
RetryOptions const& retryOptions,
int32_t attempt,
std::chrono::milliseconds& retryAfter,
double jitterFactor) const override
{
return m_shouldRetryOnResponse(response, retryOptions, attempt, retryAfter, jitterFactor);
}
};

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions