mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-09 21:09:51 +00:00
[FEAT] Adding in handling for secondary rate limit exceptions (#2473)
This commit is contained in:
@@ -180,7 +180,7 @@ namespace Octokit.Tests.Http
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ThrowsRateLimitExceededExceptionForForbidderResponse()
|
||||
public async Task ThrowsRateLimitExceededExceptionForForbiddenResponse()
|
||||
{
|
||||
var httpClient = Substitute.For<IHttpClient>();
|
||||
var response = CreateResponse(
|
||||
@@ -202,6 +202,28 @@ namespace Octokit.Tests.Http
|
||||
exception.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ThrowsSecondaryRateLimitExceededExceptionForForbiddenResponse()
|
||||
{
|
||||
var httpClient = Substitute.For<IHttpClient>();
|
||||
var response = CreateResponse(
|
||||
HttpStatusCode.Forbidden,
|
||||
"{\"message\":\"You have exceeded a secondary rate limit. Please wait a few minutes before you try again.\"}");
|
||||
|
||||
httpClient.Send(Args.Request, Args.CancellationToken).Returns(Task.FromResult(response));
|
||||
var connection = new Connection(new ProductHeaderValue("OctokitTests"),
|
||||
_exampleUri,
|
||||
Substitute.For<ICredentialStore>(),
|
||||
httpClient,
|
||||
Substitute.For<IJsonSerializer>());
|
||||
|
||||
var exception = await Assert.ThrowsAsync<SecondaryRateLimitExceededException>(
|
||||
() => connection.GetResponse<string>(new Uri("endpoint", UriKind.Relative)));
|
||||
|
||||
Assert.Equal("You have exceeded a secondary rate limit. Please wait a few minutes before you try again.",
|
||||
exception.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ThrowsLoginAttemptsExceededExceptionForForbiddenResponse()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user