-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Added ApiOption overloads to methods on IRepositoryPagesClient and IObservableRepositoryPagesClient #1213
Added ApiOption overloads to methods on IRepositoryPagesClient and IObservableRepositoryPagesClient #1213
Changes from 5 commits
9c0aeca
1255be4
2682e1e
99e6d7e
948fcdb
eb73e97
ee7dcbd
2a5da0f
e5545c7
c1b6f24
7f83e74
8ca8227
2f1943a
96818f4
9b38fff
a9fcefa
33d237a
8313864
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,26 @@ public IObservable<PagesBuild> GetAll(string owner, string repositoryName) | |
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); | ||
|
||
return _connection.GetAndFlattenAllPages<PagesBuild>(ApiUrls.RepositoryPageBuilds(owner, repositoryName)); | ||
return GetAll(owner, repositoryName, ApiOptions.None); | ||
} | ||
|
||
/// <summary> | ||
/// Gets all build metadata for a given repository | ||
/// </summary> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="repositoryName">The name of the repository</param> | ||
/// <param name="options">Options to change the behaviour of the API</param> | ||
/// <remarks> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whitespace |
||
/// See the <a href="https://developer.github.com/v3/repos/pages/#list-pages-builds">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <returns></returns> | ||
public IObservable<PagesBuild> GetAll(string owner, string repositoryName, ApiOptions options) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); | ||
Ensure.ArgumentNotNull(options, "options"); | ||
|
||
return _connection.GetAndFlattenAllPages<PagesBuild>(ApiUrls.RepositoryPageBuilds(owner, repositoryName), options); | ||
} | ||
|
||
/// <summary> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using System.Reactive.Linq; | ||
using System.Threading.Tasks; | ||
using Octokit.Reactive; | ||
using Xunit; | ||
|
||
namespace Octokit.Tests.Integration.Reactive | ||
{ | ||
public class ObservableRepositoryPagesClientTests | ||
{ | ||
public class TheGetAllMethod | ||
{ | ||
readonly ObservableRepositoryPagesClient _repositoryPagesClient; | ||
const string owner = "octokit"; | ||
const string name = "octokit.net"; | ||
|
||
public TheGetAllMethod() | ||
{ | ||
var github = Helper.GetAuthenticatedClient(); | ||
|
||
_repositoryPagesClient = new ObservableRepositoryPagesClient(github); | ||
} | ||
|
||
[IntegrationTest] | ||
public async Task ReturnsRepositoryPages() | ||
{ | ||
var pages = await _repositoryPagesClient.GetAll(owner, name).ToList(); | ||
|
||
Assert.NotEmpty(pages); | ||
} | ||
|
||
[IntegrationTest] | ||
public async Task ReturnsCorrectCountOfPagesWithoutStart() | ||
{ | ||
var options = new ApiOptions | ||
{ | ||
PageSize = 5, | ||
PageCount = 1 | ||
}; | ||
|
||
var pages = await _repositoryPagesClient.GetAll(owner, name, options).ToList(); | ||
Assert.Equal(5, pages.Count); | ||
} | ||
|
||
[IntegrationTest] | ||
public async Task ReturnCorrectCountOfPagesWithStart() | ||
{ | ||
var options = new ApiOptions | ||
{ | ||
PageSize = 5, | ||
PageCount = 1, | ||
StartPage = 2 | ||
}; | ||
|
||
var pages = await _repositoryPagesClient.GetAll(owner, name, options).ToList(); | ||
Assert.Equal(5, pages.Count); | ||
} | ||
|
||
[IntegrationTest] | ||
public async Task ReturnsDistinctResultsBasedOnStartPage() | ||
{ | ||
var startOptions = new ApiOptions | ||
{ | ||
PageSize = 5, | ||
PageCount = 1 | ||
}; | ||
|
||
var firstPage = await _repositoryPagesClient.GetAll(owner, name, startOptions).ToList(); | ||
|
||
var skipStartOptions = new ApiOptions | ||
{ | ||
PageSize = 5, | ||
PageCount = 1, | ||
StartPage = 2 | ||
}; | ||
|
||
var secondPage = await _repositoryPagesClient.GetAll(owner, name, skipStartOptions).ToList(); | ||
|
||
Assert.NotEqual(firstPage[0].Url, secondPage[0].Url); | ||
Assert.NotEqual(firstPage[1].Url, secondPage[1].Url); | ||
Assert.NotEqual(firstPage[2].Url, secondPage[2].Url); | ||
Assert.NotEqual(firstPage[3].Url, secondPage[3].Url); | ||
Assert.NotEqual(firstPage[4].Url, secondPage[4].Url); | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ public async Task EnsuresNonNullArguments() | |
} | ||
} | ||
|
||
public class TheGetBuildsMethod | ||
public class TheGetAllBuildsMethod | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💄 this should be |
||
{ | ||
[Fact] | ||
public void RequestsCorrectUrl() | ||
|
@@ -41,7 +41,7 @@ public void RequestsCorrectUrl() | |
|
||
client.GetAll("fake", "repo"); | ||
|
||
connection.Received().GetAll<PagesBuild>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pages/builds")); | ||
connection.Received().GetAll<PagesBuild>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pages/builds"), Args.ApiOptions); | ||
} | ||
|
||
[Fact] | ||
|
@@ -50,8 +50,9 @@ public async Task EnsuresNonNullArguments() | |
var connection = Substitute.For<IApiConnection>(); | ||
var client = new RepositoryPagesClient(connection); | ||
|
||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name")); | ||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null)); | ||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name", new ApiOptions())); | ||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, new ApiOptions())); | ||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", null)); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add a |
||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ public interface IRepositoryPagesClient | |
/// <returns></returns> | ||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] | ||
Task<Page> Get(string owner, string repositoryName); | ||
|
||
/// <summary> | ||
/// Gets all build metadata for a given repository | ||
/// </summary> | ||
|
@@ -33,6 +34,19 @@ public interface IRepositoryPagesClient | |
/// </remarks> | ||
/// <returns></returns> | ||
Task<IReadOnlyList<PagesBuild>> GetAll(string owner, string repositoryName); | ||
|
||
/// <summary> | ||
/// Gets all build metadata for a given repository | ||
/// </summary> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="repositoryName">The name of the repository</param> | ||
/// <param name="options">Options for changing the behaviour of the API</param> | ||
/// <remarks> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extraneous whitespace here? 2 spaces in Also should the description of
|
||
/// See the <a href="https://developer.github.com/v3/repos/pages/#list-pages-builds">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <returns></returns> | ||
Task<IReadOnlyList<PagesBuild>> GetAll(string owner, string repositoryName, ApiOptions options); | ||
|
||
/// <summary> | ||
/// Gets the build metadata for the last build for a given repository | ||
/// </summary> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace