-
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
Add support for passing sort options to IssueCommentsClient.GetAllForRepository() #1501
Changes from 6 commits
baabb98
fa9d3e7
2dd5336
1a7a50a
297025f
14a11b9
cd86f24
0e13194
6d37397
ece289f
3f58504
7fb0768
34004ac
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 |
---|---|---|
|
@@ -87,7 +87,7 @@ public IObservable<IssueComment> GetAllForRepository(string owner, string name, | |
Ensure.ArgumentNotNullOrEmptyString(name, "name"); | ||
Ensure.ArgumentNotNull(options, "options"); | ||
|
||
return _connection.GetAndFlattenAllPages<IssueComment>(ApiUrls.IssueComments(owner, name), null, AcceptHeaders.ReactionsPreview, options); | ||
return GetAllForRepository(owner, name, new IssueCommentRequest(), ApiOptions.None); | ||
} | ||
|
||
/// <summary> | ||
|
@@ -100,7 +100,69 @@ public IObservable<IssueComment> GetAllForRepository(long repositoryId, ApiOptio | |
{ | ||
Ensure.ArgumentNotNull(options, "options"); | ||
|
||
return _connection.GetAndFlattenAllPages<IssueComment>(ApiUrls.IssueComments(repositoryId), options); | ||
return GetAllForRepository(repositoryId, new IssueCommentRequest(), ApiOptions.None); | ||
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 passing through the options variable rather than ApiOptions.None 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. Ah... thanks. |
||
} | ||
|
||
/// <summary> | ||
/// Gets Issue Comments for a repository. | ||
/// </summary> | ||
/// <remarks>http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository</remarks> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="name">The name of the repository</param> | ||
/// <param name="request">The sorting <see cref="IssueCommentRequest">parameters</see></param> | ||
public IObservable<IssueComment> GetAllForRepository(string owner, string name, IssueCommentRequest request) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(name, "name"); | ||
Ensure.ArgumentNotNull(request, "request"); | ||
|
||
return GetAllForRepository(owner, name, request, ApiOptions.None); | ||
} | ||
|
||
/// <summary> | ||
/// Gets Issue Comments for a repository. | ||
/// </summary> | ||
/// <remarks>http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository</remarks> | ||
/// <param name="repositoryId">The Id of the repository</param> | ||
/// <param name="request">The sorting <see cref="IssueCommentRequest">parameters</see></param> | ||
public IObservable<IssueComment> GetAllForRepository(long repositoryId, IssueCommentRequest request) | ||
{ | ||
Ensure.ArgumentNotNull(request, "request"); | ||
|
||
return GetAllForRepository(repositoryId, request, ApiOptions.None); | ||
} | ||
|
||
/// <summary> | ||
/// Gets Issue Comments for a repository. | ||
/// </summary> | ||
/// <remarks>http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository</remarks> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="name">The name of the repository</param> | ||
/// <param name="request">The sorting <see cref="IssueCommentRequest">parameters</see></param> | ||
/// <param name="options">Options for changing the API response</param> | ||
public IObservable<IssueComment> GetAllForRepository(string owner, string name, IssueCommentRequest request, ApiOptions options) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(name, "name"); | ||
Ensure.ArgumentNotNull(request, "request"); | ||
Ensure.ArgumentNotNull(options, "options"); | ||
|
||
return _connection.GetAndFlattenAllPages<IssueComment>(ApiUrls.IssueComments(owner, name), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); | ||
} | ||
|
||
/// <summary> | ||
/// Gets Issue Comments for a repository. | ||
/// </summary> | ||
/// <remarks>http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository</remarks> | ||
/// <param name="repositoryId">The Id of the repository</param> | ||
/// <param name="request">The sorting <see cref="IssueCommentRequest">parameters</see></param> | ||
/// <param name="options">Options for changing the API response</param> | ||
public IObservable<IssueComment> GetAllForRepository(long repositoryId, IssueCommentRequest request, ApiOptions options) | ||
{ | ||
Ensure.ArgumentNotNull(request, "request"); | ||
Ensure.ArgumentNotNull(options, "options"); | ||
|
||
return _connection.GetAndFlattenAllPages<IssueComment>(ApiUrls.IssueComments(repositoryId), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); | ||
} | ||
|
||
/// <summary> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,8 +57,8 @@ public void RequestsCorrectUrl() | |
client.GetAllForRepository("fake", "repo"); | ||
|
||
gitHubClient.Connection.Received(1).Get<List<IssueComment>>( | ||
new Uri("repos/fake/repo/issues/comments", UriKind.Relative), | ||
Args.EmptyDictionary, | ||
new Uri("repos/fake/repo/issues/comments", UriKind.Relative), | ||
Arg.Any<IDictionary<string, string>>(), | ||
"application/vnd.github.squirrel-girl-preview"); | ||
} | ||
|
||
|
@@ -71,7 +71,7 @@ public void RequestsCorrectUrlWithRepositoryId() | |
client.GetAllForRepository(1); | ||
|
||
gitHubClient.Connection.Received(1).Get<List<IssueComment>>( | ||
new Uri("repositories/1/issues/comments", UriKind.Relative), Args.EmptyDictionary, null); | ||
new Uri("repositories/1/issues/comments", UriKind.Relative), Arg.Any<IDictionary<string, string>>(), null); | ||
} | ||
|
||
[Fact] | ||
|
@@ -80,6 +80,12 @@ public void RequestsCorrectUrlWithApiOptions() | |
var gitHubClient = Substitute.For<IGitHubClient>(); | ||
var client = new ObservableIssueCommentsClient(gitHubClient); | ||
|
||
var request = new IssueCommentRequest() | ||
{ | ||
Direction = SortDirection.Ascending, | ||
Since = DateTime.UtcNow, | ||
Sort = PullRequestReviewCommentSort.Created | ||
}; | ||
var options = new ApiOptions | ||
{ | ||
StartPage = 1, | ||
|
@@ -89,10 +95,7 @@ public void RequestsCorrectUrlWithApiOptions() | |
|
||
client.GetAllForRepository("fake", "repo", options); | ||
|
||
gitHubClient.Connection.Received(1).Get<List<IssueComment>>( | ||
new Uri("repos/fake/repo/issues/comments", UriKind.Relative), | ||
Arg.Any<Dictionary<string, string>>(), | ||
"application/vnd.github.squirrel-girl-preview"); | ||
gitHubClient.Received().Issue.Comment.GetAllForRepository("fake", "repo", request, options); | ||
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. Id say this is the one failing, if you have a look at what the previous code was 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. These tests aren't right. They arent failing but they also aren't correct. It may be something to do with the multiple nested subclients on the end of the but this observable method doesnt actually call into the |
||
} | ||
|
||
[Fact] | ||
|
@@ -101,6 +104,12 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() | |
var gitHubClient = Substitute.For<IGitHubClient>(); | ||
var client = new ObservableIssueCommentsClient(gitHubClient); | ||
|
||
var request = new IssueCommentRequest() | ||
{ | ||
Direction = SortDirection.Ascending, | ||
Since = DateTime.UtcNow, | ||
Sort = PullRequestReviewCommentSort.Created | ||
}; | ||
var options = new ApiOptions | ||
{ | ||
StartPage = 1, | ||
|
@@ -110,8 +119,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() | |
|
||
client.GetAllForRepository(1, options); | ||
|
||
gitHubClient.Connection.Received(1).Get<List<IssueComment>>( | ||
new Uri("repositories/1/issues/comments", UriKind.Relative), Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null); | ||
gitHubClient.Received().Issue.Comment.GetAllForRepository(1, request, options); | ||
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. and this one too 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. @ryangribble sry, I'm not famillar with unit testing. I'll make a fix. |
||
} | ||
|
||
[Fact] | ||
|
@@ -124,9 +132,11 @@ public async Task EnsuresNonNullArguments() | |
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null)); | ||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", ApiOptions.None)); | ||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, ApiOptions.None)); | ||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null)); | ||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", request: null)); | ||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", options: null)); | ||
|
||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, null)); | ||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, request: null)); | ||
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, options: null)); | ||
|
||
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name")); | ||
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "")); | ||
|
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.
This should be passing through the
options
variable rather thanApiOptions.None