From 3618236be3ecb3593beafb1653d9b157310a635f Mon Sep 17 00:00:00 2001 From: Devesh Khandelwal Date: Mon, 14 Mar 2016 11:06:22 +0530 Subject: [PATCH 1/7] Add overloads for ApiOptions in Assignees API. --- Octokit.Tests/Clients/AssigneesClientTests.cs | 2 +- Octokit/Clients/AssigneesClient.cs | 18 ++++++++++++++++++ Octokit/Clients/IAssigneesClient.cs | 9 +++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Octokit.Tests/Clients/AssigneesClientTests.cs b/Octokit.Tests/Clients/AssigneesClientTests.cs index 12615271..e067c688 100644 --- a/Octokit.Tests/Clients/AssigneesClientTests.cs +++ b/Octokit.Tests/Clients/AssigneesClientTests.cs @@ -21,7 +21,7 @@ namespace Octokit.Tests.Clients client.GetAllForRepository("fake", "repo"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/assignees")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/assignees"), null, AcceptHeaders.StableVersion, Args.ApiOptions); } [Fact] diff --git a/Octokit/Clients/AssigneesClient.cs b/Octokit/Clients/AssigneesClient.cs index f66b5dc1..16036c08 100644 --- a/Octokit/Clients/AssigneesClient.cs +++ b/Octokit/Clients/AssigneesClient.cs @@ -33,6 +33,24 @@ namespace Octokit return ApiConnection.GetAll(ApiUrls.Assignees(owner, name)); } + /// + /// Gets all the available assignees (owner + collaborators) to which issues may be assigned. + /// + /// The owner of the repository + /// The name of the repository + /// The options to change API's response. + /// + public Task> GetAllForRepository(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + var endpoint = ApiUrls.Assignees(owner, name); + + return ApiConnection.GetAll(endpoint, null, options); + } + /// /// Checks to see if a user is an assignee for a repository. /// diff --git a/Octokit/Clients/IAssigneesClient.cs b/Octokit/Clients/IAssigneesClient.cs index 2a1e0cdf..f3bc5b79 100644 --- a/Octokit/Clients/IAssigneesClient.cs +++ b/Octokit/Clients/IAssigneesClient.cs @@ -19,6 +19,15 @@ namespace Octokit /// Task> GetAllForRepository(string owner, string name); + /// + /// Gets all the available assignees (owner + collaborators) to which issues may be assigned. + /// + /// The owner of the repository + /// The name of the repository + /// The options to chagne API's response. + /// + Task> GetAllForRepository(string owner, string name, ApiOptions options); + /// /// Checks to see if a user is an assignee for a repository. /// From 829ba2c5609b6f1ab40b9dd89cab529aecd91c79 Mon Sep 17 00:00:00 2001 From: Devesh Khandelwal Date: Mon, 14 Mar 2016 11:25:29 +0530 Subject: [PATCH 2/7] Add reactive overloads for ApiOptions in Assignees API. --- .../Clients/IObservableAssigneesClient.cs | 9 ++ .../Clients/ObservableAssigneesClient.cs | 15 ++++ .../Octokit.Tests.Integration.csproj | 1 + .../ObservableAssigneesClientTests.cs | 88 +++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 Octokit.Tests.Integration/Reactive/ObservableAssigneesClientTests.cs diff --git a/Octokit.Reactive/Clients/IObservableAssigneesClient.cs b/Octokit.Reactive/Clients/IObservableAssigneesClient.cs index b4be296d..b47ad18e 100644 --- a/Octokit.Reactive/Clients/IObservableAssigneesClient.cs +++ b/Octokit.Reactive/Clients/IObservableAssigneesClient.cs @@ -12,6 +12,15 @@ namespace Octokit.Reactive /// IObservable GetAllForRepository(string owner, string name); + /// + /// Gets all the available assignees (owner + collaborators) to which issues may be assigned. + /// + /// The owner of the repository + /// The name of the repository + /// The options to change API's behaviour. + /// + IObservable GetAllForRepository(string owner, string name, ApiOptions options); + /// /// Checks to see if a user is an assignee for a repository. /// diff --git a/Octokit.Reactive/Clients/ObservableAssigneesClient.cs b/Octokit.Reactive/Clients/ObservableAssigneesClient.cs index 63fe37d7..814d158d 100644 --- a/Octokit.Reactive/Clients/ObservableAssigneesClient.cs +++ b/Octokit.Reactive/Clients/ObservableAssigneesClient.cs @@ -31,6 +31,21 @@ namespace Octokit.Reactive return _connection.GetAndFlattenAllPages(ApiUrls.Assignees(owner, name)); } + /// + /// Gets all the available assignees (owner + collaborators) to which issues may be assigned. + /// + /// The owner of the repository + /// The name of the repository + /// + public IObservable GetAllForRepository(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Assignees(owner, name), options); + } + /// /// Checks to see if a user is an assignee for a repository. /// diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 5b843b6e..0a5c12a3 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -137,6 +137,7 @@ + diff --git a/Octokit.Tests.Integration/Reactive/ObservableAssigneesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableAssigneesClientTests.cs new file mode 100644 index 00000000..a85f326b --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableAssigneesClientTests.cs @@ -0,0 +1,88 @@ +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableAssigneesClientTests + { + public class TheGetAllMethod + { + readonly ObservableAssigneesClient _assigneesClient; + const string owner = "octokit"; + const string name = "octokit.net"; + + public TheGetAllMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _assigneesClient = new ObservableAssigneesClient(github); + } + + [IntegrationTest] + public async Task ReturnsAssignees() + { + var assignees = await _assigneesClient.GetAllForRepository(owner, name).ToList(); + + Assert.NotEmpty(assignees); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfAssigneesWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var assignees = await _assigneesClient.GetAllForRepository(owner, name, options).ToList(); + + Assert.Equal(5, assignees.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfAssigneesWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var releases = await _assigneesClient.GetAllForRepository(owner, name, options).ToList(); + + Assert.Equal(5, releases.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstPage = await _assigneesClient.GetAllForRepository(owner, name, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await _assigneesClient.GetAllForRepository(owner, name, skipStartOptions).ToList(); + + Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + Assert.NotEqual(firstPage[1].Id, secondPage[1].Id); + Assert.NotEqual(firstPage[2].Id, secondPage[2].Id); + Assert.NotEqual(firstPage[3].Id, secondPage[3].Id); + Assert.NotEqual(firstPage[4].Id, secondPage[4].Id); + } + } + } +} \ No newline at end of file From abc4eb9269a75c5bf40fd9bad79f03cdbbeda1f3 Mon Sep 17 00:00:00 2001 From: Devesh Khandelwal Date: Tue, 15 Mar 2016 15:27:19 +0530 Subject: [PATCH 3/7] Oops. Forgot to actually call the overload I added. --- Octokit.Reactive/Clients/ObservableAssigneesClient.cs | 1 + Octokit.Tests/Clients/AssigneesClientTests.cs | 6 +++++- Octokit/Clients/AssigneesClient.cs | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Octokit.Reactive/Clients/ObservableAssigneesClient.cs b/Octokit.Reactive/Clients/ObservableAssigneesClient.cs index 814d158d..28717934 100644 --- a/Octokit.Reactive/Clients/ObservableAssigneesClient.cs +++ b/Octokit.Reactive/Clients/ObservableAssigneesClient.cs @@ -36,6 +36,7 @@ namespace Octokit.Reactive /// /// The owner of the repository /// The name of the repository + /// The options to change API's behaviour /// public IObservable GetAllForRepository(string owner, string name, ApiOptions options) { diff --git a/Octokit.Tests/Clients/AssigneesClientTests.cs b/Octokit.Tests/Clients/AssigneesClientTests.cs index e067c688..ac4a7bc0 100644 --- a/Octokit.Tests/Clients/AssigneesClientTests.cs +++ b/Octokit.Tests/Clients/AssigneesClientTests.cs @@ -21,7 +21,11 @@ namespace Octokit.Tests.Clients client.GetAllForRepository("fake", "repo"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/assignees"), null, AcceptHeaders.StableVersion, Args.ApiOptions); + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "repos/fake/repo/assignees"), + null, + AcceptHeaders.StableVersion, + Args.ApiOptions); } [Fact] diff --git a/Octokit/Clients/AssigneesClient.cs b/Octokit/Clients/AssigneesClient.cs index 16036c08..58ca8666 100644 --- a/Octokit/Clients/AssigneesClient.cs +++ b/Octokit/Clients/AssigneesClient.cs @@ -30,7 +30,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.GetAll(ApiUrls.Assignees(owner, name)); + return GetAllForRepository(owner, name, ApiOptions.None); } /// @@ -48,7 +48,7 @@ namespace Octokit var endpoint = ApiUrls.Assignees(owner, name); - return ApiConnection.GetAll(endpoint, null, options); + return ApiConnection.GetAll(endpoint, null, AcceptHeaders.StableVersion, options); } /// From effecdf4b491f7df6a33bfd977bae4c6c482e6bf Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 16 Mar 2016 10:45:25 +1100 Subject: [PATCH 4/7] quiet nuget.exe when loading pre-requisities --- build.cmd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.cmd b/build.cmd index d5ac4da4..393b128f 100644 --- a/build.cmd +++ b/build.cmd @@ -1,9 +1,9 @@ @echo off -"tools\nuget\nuget.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.1.0" -"tools\nuget\nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.4.2" -"tools\nuget\nuget.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0" -"tools\nuget\nuget.exe" "install" "Octokit.CodeFormatter" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.0.0-preview" -Pre +"tools\nuget\nuget.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.1.0" -verbosity quiet +"tools\nuget\nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.4.2" -verbosity quiet +"tools\nuget\nuget.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0" -verbosity quiet +"tools\nuget\nuget.exe" "install" "Octokit.CodeFormatter" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.0.0-preview" -Pre -verbosity quiet :Build cls From 07b7fc4985b778a17e32976dd2d00eadf0ef165f Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 16 Mar 2016 12:55:21 +1100 Subject: [PATCH 5/7] quiet build output for other environment --- build.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/build.sh b/build.sh index 907b1b01..5706630d 100755 --- a/build.sh +++ b/build.sh @@ -3,16 +3,16 @@ if test "$OS" = "Windows_NT" then # use .Net -"./tools/nuget/nuget.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.0.0" -"./tools/nuget/nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.4.2" -"./tools/nuget/nuget.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0" -packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx +"./tools/nuget/nuget.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.0.0" -verbosity quiet +"./tools/nuget/nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.4.2" -verbosity quiet +"./tools/nuget/nuget.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0" -verbosity quiet +packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx else # use mono -mono "./tools/nuget/NuGet.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.0.0" -mono "./tools/nuget/NuGet.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.4.2" -mono "./tools/nuget/NuGet.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0" -mono "./tools/nuget/NuGet.exe" "install" "System.Net.Http" "-OutputDirectory" "tools" -mono "./tools/nuget/NuGet.exe" "install" "Microsoft.Net.Http" "-OutputDirectory" "tools" -mono ./tools/FAKE.Core/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx +mono "./tools/nuget/NuGet.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.0.0" -verbosity quiet +mono "./tools/nuget/NuGet.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.4.2" -verbosity quiet +mono "./tools/nuget/NuGet.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0" -verbosity quiet +mono "./tools/nuget/NuGet.exe" "install" "System.Net.Http" "-OutputDirectory" "tools" -verbosity quiet +mono "./tools/nuget/NuGet.exe" "install" "Microsoft.Net.Http" "-OutputDirectory" "tools" -verbosity quiet +mono ./tools/FAKE.Core/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx fi From f3f7656492f24431e10ae61b1b2b5c4ba9c12f23 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 16 Mar 2016 12:56:18 +1100 Subject: [PATCH 6/7] make CodeFormatter available when running script as well --- build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.sh b/build.sh index 5706630d..f6294bc4 100755 --- a/build.sh +++ b/build.sh @@ -6,12 +6,14 @@ then "./tools/nuget/nuget.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.0.0" -verbosity quiet "./tools/nuget/nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.4.2" -verbosity quiet "./tools/nuget/nuget.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0" -verbosity quiet +"./tools/nuget/nuget.exe" "install" "Octokit.CodeFormatter" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.0.0-preview" -Pre -verbosity quiet packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx else # use mono mono "./tools/nuget/NuGet.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.0.0" -verbosity quiet mono "./tools/nuget/NuGet.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.4.2" -verbosity quiet mono "./tools/nuget/NuGet.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0" -verbosity quiet +mono "./tools/nuget/NuGet.exe" "install" "Octokit.CodeFormatter" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.0.0-preview" -Pre -verbosity quiet mono "./tools/nuget/NuGet.exe" "install" "System.Net.Http" "-OutputDirectory" "tools" -verbosity quiet mono "./tools/nuget/NuGet.exe" "install" "Microsoft.Net.Http" "-OutputDirectory" "tools" -verbosity quiet mono ./tools/FAKE.Core/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx From 4c9057b00968fe5b68cbc7db03ded6dd0594874f Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 16 Mar 2016 13:08:06 +1100 Subject: [PATCH 7/7] bump FAKE to latest version --- build.cmd | 2 +- build.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.cmd b/build.cmd index 393b128f..3e500ca4 100644 --- a/build.cmd +++ b/build.cmd @@ -1,7 +1,7 @@ @echo off "tools\nuget\nuget.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.1.0" -verbosity quiet -"tools\nuget\nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.4.2" -verbosity quiet +"tools\nuget\nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.22.2" -verbosity quiet "tools\nuget\nuget.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0" -verbosity quiet "tools\nuget\nuget.exe" "install" "Octokit.CodeFormatter" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.0.0-preview" -Pre -verbosity quiet diff --git a/build.sh b/build.sh index f6294bc4..3c455fb4 100755 --- a/build.sh +++ b/build.sh @@ -4,14 +4,14 @@ then # use .Net "./tools/nuget/nuget.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.0.0" -verbosity quiet -"./tools/nuget/nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.4.2" -verbosity quiet +"./tools/nuget/nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.22.2" -verbosity quiet "./tools/nuget/nuget.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0" -verbosity quiet "./tools/nuget/nuget.exe" "install" "Octokit.CodeFormatter" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.0.0-preview" -Pre -verbosity quiet packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx else # use mono mono "./tools/nuget/NuGet.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.0.0" -verbosity quiet -mono "./tools/nuget/NuGet.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.4.2" -verbosity quiet +mono "./tools/nuget/NuGet.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.22.2" -verbosity quiet mono "./tools/nuget/NuGet.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0" -verbosity quiet mono "./tools/nuget/NuGet.exe" "install" "Octokit.CodeFormatter" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.0.0-preview" -Pre -verbosity quiet mono "./tools/nuget/NuGet.exe" "install" "System.Net.Http" "-OutputDirectory" "tools" -verbosity quiet