diff --git a/Octokit.Tests.Integration/Clients/SearchClientTests.cs b/Octokit.Tests.Integration/Clients/SearchClientTests.cs index 14319e91..a00e4279 100644 --- a/Octokit.Tests.Integration/Clients/SearchClientTests.cs +++ b/Octokit.Tests.Integration/Clients/SearchClientTests.cs @@ -23,6 +23,30 @@ public class SearchClientTests Assert.NotEmpty(repos.Items); } + [IntegrationTest] + public async Task SearchForForkedRepositories() + { + var request = new SearchRepositoriesRequest("octokit") + { + Fork = ForkQualifier.IncludeForks + }; + var repos = await _gitHubClient.Search.SearchRepo(request); + + Assert.True(repos.Items.Any(x => x.Fork)); + } + + [IntegrationTest] + public async Task SearchForOnlyForkedRepositories() + { + var request = new SearchRepositoriesRequest("octokit") + { + Fork = ForkQualifier.OnlyForks + }; + var repos = await _gitHubClient.Search.SearchRepo(request); + + Assert.True(repos.Items.All(x => x.Fork)); + } + [IntegrationTest] public async Task SearchForGitHub() { diff --git a/Octokit.Tests/Clients/SearchClientTests.cs b/Octokit.Tests/Clients/SearchClientTests.cs index e216eb8f..a4eba60b 100644 --- a/Octokit.Tests/Clients/SearchClientTests.cs +++ b/Octokit.Tests/Clients/SearchClientTests.cs @@ -428,7 +428,7 @@ namespace Octokit.Tests.Clients } [Fact] - public void TestingTheForkQualifier() + public void TestingTheIncludeForkQualifier() { var connection = Substitute.For(); var client = new SearchClient(connection); @@ -437,7 +437,20 @@ namespace Octokit.Tests.Clients request.Fork = ForkQualifier.IncludeForks; client.SearchRepo(request); connection.Received().Get(Arg.Is(u => u.ToString() == "search/repositories"), - Arg.Is>(d => d["q"] == "github+fork:IncludeForks")); + Arg.Is>(d => d["q"] == "github+fork:true")); + } + + [Fact] + public void TestingTheOnlyForkQualifier() + { + var connection = Substitute.For(); + var client = new SearchClient(connection); + //search repos that contains rails and forks are included in the search + var request = new SearchRepositoriesRequest("github"); + request.Fork = ForkQualifier.OnlyForks; + client.SearchRepo(request); + connection.Received().Get(Arg.Is(u => u.ToString() == "search/repositories"), + Arg.Is>(d => d["q"] == "github+fork:only")); } [Fact] diff --git a/Octokit/Models/Request/SearchRepositoriesRequest.cs b/Octokit/Models/Request/SearchRepositoriesRequest.cs index 1ccf0553..61530922 100644 --- a/Octokit/Models/Request/SearchRepositoriesRequest.cs +++ b/Octokit/Models/Request/SearchRepositoriesRequest.cs @@ -133,7 +133,7 @@ namespace Octokit if (Fork != null) { - parameters.Add(string.Format(CultureInfo.InvariantCulture, "fork:{0}", Fork)); + parameters.Add(string.Format(CultureInfo.InvariantCulture, "fork:{0}", Fork.ToParameter())); } if (Stars != null) @@ -780,12 +780,12 @@ namespace Octokit /// /// only search for forked repos /// - [Parameter(Value = "Only")] + [Parameter(Value = "only")] OnlyForks, /// /// include forked repos into the search /// - [Parameter(Value = "True")] + [Parameter(Value = "true")] IncludeForks } } \ No newline at end of file