diff --git a/Octokit.Tests.Integration/Clients/RateLimitClientTests.cs b/Octokit.Tests.Integration/Clients/RateLimitClientTests.cs index 9719383836..1dc61ba464 100644 --- a/Octokit.Tests.Integration/Clients/RateLimitClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RateLimitClientTests.cs @@ -9,7 +9,6 @@ public class RateLimitClientTests public async Task CanRetrieveResourceRateLimits() { var github = Helper.GetAuthenticatedClient(); - var result = await github.RateLimit.GetRateLimits(); // Test the core limits @@ -26,6 +25,13 @@ public async Task CanRetrieveResourceRateLimits() Assert.True(result.Resources.Search.ResetAsUtcEpochSeconds > 0); Assert.NotEqual(default, result.Resources.Search.Reset); + // Test the graphql limits + Assert.True(result.Resources.Graphql.Limit > 0); + Assert.True(result.Resources.Graphql.Remaining > -1); + Assert.True(result.Resources.Graphql.Remaining <= result.Resources.Graphql.Limit); + Assert.True(result.Resources.Graphql.ResetAsUtcEpochSeconds > 0); + Assert.NotEqual(default, result.Resources.Graphql.Reset); + // Test the depreciated rate limits Assert.True(result.Rate.Limit > 0); Assert.True(result.Rate.Remaining > -1); diff --git a/Octokit.Tests/Clients/MiscellaneousClientTests.cs b/Octokit.Tests/Clients/MiscellaneousClientTests.cs index 7a184d02da..4253eb8e54 100644 --- a/Octokit.Tests/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests/Clients/MiscellaneousClientTests.cs @@ -94,7 +94,8 @@ public async Task RequestsTheResourceRateLimitEndpoint() var rateLimit = new MiscellaneousRateLimit( new ResourceRateLimit( new RateLimit(5000, 4999, 1372700873), - new RateLimit(30, 18, 1372700873) + new RateLimit(30, 18, 1372700873), + new RateLimit(5000, 4999, 1372700873) ), new RateLimit(100, 75, 1372700873) ); @@ -102,7 +103,6 @@ public async Task RequestsTheResourceRateLimitEndpoint() apiConnection.Get(Arg.Is(u => u.ToString() == "rate_limit")).Returns(Task.FromResult(rateLimit)); var client = new MiscellaneousClient(apiConnection); - var result = await client.GetRateLimits(); // Test the core limits @@ -125,6 +125,16 @@ public async Task RequestsTheResourceRateLimitEndpoint() CultureInfo.InvariantCulture); Assert.Equal(expectedReset, result.Resources.Search.Reset); + // Test the graphql limits + Assert.Equal(5000, result.Resources.Graphql.Limit); + Assert.Equal(4999, result.Resources.Graphql.Remaining); + Assert.Equal(1372700873, result.Resources.Graphql.ResetAsUtcEpochSeconds); + expectedReset = DateTimeOffset.ParseExact( + "Mon 01 Jul 2013 5:47:53 PM -00:00", + "ddd dd MMM yyyy h:mm:ss tt zzz", + CultureInfo.InvariantCulture); + Assert.Equal(expectedReset, result.Resources.Graphql.Reset); + // Test the depreciated rate limits Assert.Equal(100, result.Rate.Limit); Assert.Equal(75, result.Rate.Remaining); diff --git a/Octokit.Tests/Clients/RateLimitClientTests.cs b/Octokit.Tests/Clients/RateLimitClientTests.cs index 4c086d0b85..f44b9d9611 100644 --- a/Octokit.Tests/Clients/RateLimitClientTests.cs +++ b/Octokit.Tests/Clients/RateLimitClientTests.cs @@ -16,7 +16,8 @@ public async Task RequestsTheResourceRateLimitEndpoint() var rateLimit = new MiscellaneousRateLimit( new ResourceRateLimit( new RateLimit(5000, 4999, 1372700873), - new RateLimit(30, 18, 1372700873) + new RateLimit(30, 18, 1372700873), + new RateLimit(5000, 4999, 1372700873) ), new RateLimit(100, 75, 1372700873) ); @@ -47,6 +48,16 @@ public async Task RequestsTheResourceRateLimitEndpoint() CultureInfo.InvariantCulture); Assert.Equal(expectedReset, result.Resources.Search.Reset); + // Test the graphql limits + Assert.Equal(5000, result.Resources.Graphql.Limit); + Assert.Equal(4999, result.Resources.Graphql.Remaining); + Assert.Equal(1372700873, result.Resources.Graphql.ResetAsUtcEpochSeconds); + expectedReset = DateTimeOffset.ParseExact( + "Mon 01 Jul 2013 5:47:53 PM -00:00", + "ddd dd MMM yyyy h:mm:ss tt zzz", + CultureInfo.InvariantCulture); + Assert.Equal(expectedReset, result.Resources.Graphql.Reset); + // Test the depreciated rate limits Assert.Equal(100, result.Rate.Limit); Assert.Equal(75, result.Rate.Remaining); diff --git a/Octokit/Models/Response/ResourceRateLimit.cs b/Octokit/Models/Response/ResourceRateLimit.cs index 6ec99c2b15..c74b55ee45 100644 --- a/Octokit/Models/Response/ResourceRateLimit.cs +++ b/Octokit/Models/Response/ResourceRateLimit.cs @@ -8,17 +8,20 @@ public class ResourceRateLimit { public ResourceRateLimit() { } - public ResourceRateLimit(RateLimit core, RateLimit search) + public ResourceRateLimit(RateLimit core, RateLimit search, RateLimit graphQL) { Ensure.ArgumentNotNull(core, nameof(core)); Ensure.ArgumentNotNull(search, nameof(search)); + Ensure.ArgumentNotNull(graphQL, nameof(graphQL)); Core = core; Search = search; + Graphql = graphQL; } + /// - /// Rate limits for core API (rate limit for everything except Search API) + /// Rate limits for core API /// public RateLimit Core { get; private set; } @@ -27,11 +30,19 @@ public ResourceRateLimit(RateLimit core, RateLimit search) /// public RateLimit Search { get; private set; } + /// + /// Rate Limits for GraphQL API + /// + public RateLimit Graphql { get; private set; } + + + internal string DebuggerDisplay { get { - return string.Format(CultureInfo.InvariantCulture, "Core: {0}; Search: {1} ", Core.DebuggerDisplay, Search.DebuggerDisplay); + return string.Format(CultureInfo.InvariantCulture, "Core: {0}; Search: {1}; GraphQL: {2} ", + Core.DebuggerDisplay, Search.DebuggerDisplay, Graphql.DebuggerDisplay); } } }